nagiosでフリーな監視をしてみよう!~nagiosの構築(3)~
PHP・apacheの初期設定
PHPとapacheの初期設定を行っていきます。
(1)apacheユーザーのホームディレクトリを変更します。
1 2 3 | # usermod -d /usr/local/apache2/htdocs apache # cat /etc/passwd | grep apache apache:x:48:48:Apache: /usr/local/apache2/htdocs : /sbin/nologin |
(2)雛形からphpの設定ファイル「php.ini」をコピーします。
1 | # cp php.ini-development /usr/local/lib/php.ini |
(3)「php.ini」ファイルに以下の内容を修正・追加します。
1 | # vi /usr/local/lib/php.ini |
・「php.ini」ファイル変更前の内容
197 198 199 200 201 202 | ; used regardless of this directive. ; Default Value: On ; Development Value: Off ; Production Value: Off ; http: //php .net /short-open-tag short_open_tag = Off |
927 928 929 930 | [Date] ; Defines the default timezone used by the date functions ; http: //php .net /date .timezone ; date .timezone = |
・「php.ini」ファイル変更後の内容
197 198 199 200 201 202 | ; used regardless of this directive. ; Default Value: On ; Development Value: Off ; Production Value: Off ; http: //php .net /short-open-tag short_open_tag = On |
927 928 929 930 | [Date] ; Defines the default timezone used by the date functions ; http: //php .net /date .timezone date .timezone = "Asia/Tokyo" |
(3)「httpd.conf」にAddTypeでphpの拡張子を指定する設定を追記します。
1 | # vi /usr/local/apache2/conf/httpd.conf |
・「httpd.conf」ファイル変更前の内容
172 173 174 175 176 177 | # running httpd, as with most system services. # User daemon Group daemon < /IfModule > |
203 204 205 206 207 | # If your host doesn't have a registered DNS name, enter its IP address here. # #ServerName www.sample.com:80 # |
258 259 260 261 262 263 264 | # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html < /IfModule > |
・「httpd.conf」ファイル変更後の内容
172 173 174 175 176 177 | # running httpd, as with most system services. # User apache Group apache < /IfModule > |
203 204 205 206 207 | # If your host doesn't have a registered DNS name, enter its IP address here. # ServerName localhost:80 # |
258 259 260 261 262 263 264 | # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.html index.php < /IfModule > |
514 515 516 517 518 | #<IfModule headers_module> #RequestHeader unset DNT env=bad_DNT #</IfModule> AddType application /x-httpd-php .php .phtml |
(4)所有者と所有グループを変更します。
1 | # chown -R apache.apache /usr/local/apache2 |
(5)サービスを再起動して、設定を有効化します。
1 2 3 | # service httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ] |
(6)phpが有効化されていることを確認するため、phpinfoのテストファイルを作成します。
1 2 | # cd /usr/local/apache2/htdocs/ # echo '<?php phpinfo();' > info.php |
(6)「http://(IPアドレス)/info.php」にアクセスして、phpinfoのページが表示されたら成功となります。
次回は、nagiosのインストールを説明していきたいと思います。