HTTPサーバ構築2
解説
構築したHTTPサーバにPHPの実行機能を追加し、SSIを有効化します。
インストール
HTTPサーバでPHPを実行するために必要なパッケージを5つインストールします。
DVDドライブにCentOS 5のDVD-ROMをセットし、以下のコマンドを実行します。
# mount /dev/cdrom /media/cdrom
# cd /media/cdrom/CentOS
# rpm -ihv gmp-4.1.4-10.el5.i386.rpm
Preparing... ########################################### [100%]
1:gmp ########################################### [100%]
# rpm -ihv php-common-5.1.6-5.el5.i386.rpm php-cli-5.1.6-5.el5.i386.rpm php-5.1.6-5.el5.i386.rpm
Preparing... ########################################### [100%]
1:php-common ########################################### [ 33%]
2:php-cli ########################################### [ 67%]
3:php ########################################### [100%]
# rpm -ihv php-mgbstring-5.1.6-5.el5.i386.rpm
Preparing... ########################################### [100%]
1:php-mbstring ########################################### [100%]
# cd /
# umount /media/cdrom
# cd /media/cdrom/CentOS
# rpm -ihv gmp-4.1.4-10.el5.i386.rpm
Preparing... ########################################### [100%]
1:gmp ########################################### [100%]
# rpm -ihv php-common-5.1.6-5.el5.i386.rpm php-cli-5.1.6-5.el5.i386.rpm php-5.1.6-5.el5.i386.rpm
Preparing... ########################################### [100%]
1:php-common ########################################### [ 33%]
2:php-cli ########################################### [ 67%]
3:php ########################################### [100%]
# rpm -ihv php-mgbstring-5.1.6-5.el5.i386.rpm
Preparing... ########################################### [100%]
1:php-mbstring ########################################### [100%]
# cd /
# umount /media/cdrom
SSIを有効化するために必要な追加パッケージはありません。
設定
SSIを有効化するための設定を行います。
ファイル名:/etc/httpd/conf/httpd.conf
※以下、該当箇所のみ変更※
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
↓変更
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddHandler server-parsed .shtml ←この行を追加
※コメント行を除外して表示しています※
<Directory "/var/www/html">
Options FollowSymLinks ExecCGI
↓変更
<Directory "/var/www/html">
Options FollowSymLinks ExecCGI IncludesNOEXEC
DirectoryIndex welcome.htm index.html index.htm index.php index.cgi
↓変更
DirectoryIndex welcome.htm index.html index.htm index.shtml index.php index.cgi
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
↓変更
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
AddHandler server-parsed .shtml ←この行を追加
※コメント行を除外して表示しています※
<Directory "/var/www/html">
Options FollowSymLinks ExecCGI
↓変更
<Directory "/var/www/html">
Options FollowSymLinks ExecCGI IncludesNOEXEC
DirectoryIndex welcome.htm index.html index.htm index.php index.cgi
↓変更
DirectoryIndex welcome.htm index.html index.htm index.shtml index.php index.cgi
PHPインストール後特に設定の変更は必要ありません。
PHPとSSI用の設定を反映するためにrcスクリプトを使用してApacheの設定をリロードします。
# /etc/rc.d/init.d/httpd reload
Reloading httpd: [ OK ]
Reloading httpd: [ OK ]
設定ファイル
/etc/httpd/conf.d/php.conf
/etc/httpd/httpd.conf