作業日記@HatenaBlog

各種の作業メモ

Apache 2.4 のインストール

パッケージのインストール

パッケージをインストールした後、ユーザ USERNAME のホームディレクトリをルートディレクトリに変更する。
CGI も有効化する。

# pkg install apache24
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    944 B   0.9kB/s    00:01
Fetching packagesite.txz: 100%    5 MiB   1.4MB/s    00:04
Processing entries: 100%
FreeBSD repository update completed. 2427B packages processed.
Updating database digests format: 100%
The following 4 package(s) will be affected (of 0 checked):
 
New packages to be INSTALLED:
        apache24: 2.4.16
        pcre: 8.37_4
        apr: 1.5.2.1.5.4
        gdbm: 1.11_2
 
The process will require 31MiB more space.
5 MiB to be downloaded.
 
Proceed with this action? [y/N]: y
Fetching...
... 
To run apache www server from startup, add apache24_enable="yes"
in your /etc/rc.conf. Extra options can be found in startup script.
 
Your hostname must be resolvable using at least 1 mechanism in
/etc/nsswitch.conf typically DNS /etc/hosts or apache might
have issues starting depending on the modules you are using.
...

サーバ設定

/etc/rc.conf の設定

# vi /etc/rc.conf
apache24_enable="yes" ←追記
/etc/hosts の設定
# vi /etc/hosts
1 localhost localhost.my.domain
127.0.0.1 localhost localhost.my.domain EXAMPLE.com ←追記
httpd.conf の設定

/tmp に展開した元サーバのコンテンツを /home/USERNAME/www-data へコピーしておく。
ルートディレクトリは www-data へ変更する。

# cd /usr/local/etc/apache24/
# cp httpd.conf httpd.conf.orig ←元ファイルをバックアップしておく
# vi httpd.conf
ServerAdmin info@EXAMPLE.com

ServerName www.EXAMPLE.com:80

DocumentRoot "/home/USERNAME/www-data/"


    Options Indexes ExecCGI FollowSymLinks
    AllowOverride All
    Require all granted



    AllowOverride None
    Options None
    Require all granted



#LoadModule cgi_module libexec/apache24/mod_cgi.so
↓
LoadModule cgi_module libexec/apache24/mod_cgi.so

ScriptAlias /cgi-bin/ "/usr/local/www/apache24/cgi-bin/"
↓
ScriptAlias /cgi-bin/ "/home/USERNAME/cgi-bin/"
Apache の起動
# /usr/local/etc/rc.d/apache24 start
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.