在FreeBSD上安装和启动Apache

这次我们将在FreeBSD上安装Apache作为Web服务器。

# pkg search apache2Apache2バージョンの検索
apache22-2.2.34_1              Version 2.2.x of Apache web server with prefork MPM
apache24-2.4.29                Version 2.4.x of Apache web server
p5-Apache2-SOAP-0.73_4         Apache2 mod_perl2 SOAP Server
p5-Apache2-SiteControl-1.05_3  Perl web site authentication/authorization system
今回は最新のApache2.4を選択しましょう

# pkg install apache24-2.4.29
インストール開始・・・

完成安装后,我们来调整Apache的设置。
今后,我认为会有各种关于Apache的设置。Apache的设置是重要的。

/usr/local/etc/apache24/httpd.conf

/usr/local/etc/apache24/httpd.conf

/usr/local/etc/apache24/httpd.conf

我們將會在這裡寫下來。
FreeBSD從初始狀態開始,就安裝了vi作為編輯器,但如果您想今後使用vim,就請安裝它。

# pkg install vim
インストール開始・・・

让我们使用Vim查看Apache的设置。

# vim /usr/local/etc/apache24/httpd.conf
#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
...Apacheについての文章や設定が書かれています

変更点は一つのみです
...
ServerName www.example.com:80
文頭のを消して下さい
...

如果对vi或vim的使用方法不清楚,可以在网上查找并进行操作。设置完成后,请退出vim。

接下来我们要进行Apache的配置以启动。

# vim /etc/rc.conf
...
apache24_enable="YES"
最終行に追記して下さい

以上是设置完成。请您退出vim。
那么,让我们确认一下已经设置的内容是否正确。

# apachectl configtest文法チェック
Performing sanity check on apache24 configuration:
Syntax OK
Syntax OKと出たら文法あってますというサイン

#apachectl startApacheスタート
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

これで完了ですもし設定を変えた際には毎回Apacheの再起動を行わないと反映されません
リスタート方法
# apachectl restart
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 30177.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

もしくは
# apachectl stop
Stopping apache24.
Waiting for PIDS: 91657.
# apachectl start
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.
を実行すれば大丈夫です

让我们来检查Apache是否正常运行。

It works.png
bannerAds