Apache2 PHP5 インストール

この章を始める前に下記の設定が必要です
「Apache2 インストール」
PHP5インストール
[root@centos ~]# yum -y install php php-gd php-mbstring php-mysql php-pear
httpd.conf編集
[root@centos ~]# vi /etc/httpd/conf/httpd.conf
DirectoryIndex index.html index.htm index.cgi
↓
DirectoryIndex index.html index.htm index.cgi index.php ←追加(index.php許可)

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php ←追加(.phpファイルを使えるようにする)
php.ini編集
[root@centos ~]# vi /etc/php.ini
short_open_tag = Off
↓
short_open_tag = On ←変更(short_open_tag有効)

expose_php = On
↓
expose_php = Off ←変更(バージョンを隠す)

max_execution_time = 30
↓
max_execution_time = 300 ←変更(スクリプト実行時間)

error_reporting  =  E_ALL
↓
error_reporting  =  E_ALL & ~E_NOTICE ←変更(注意メッセージ以外の全てのエラーを表示する)

display_errors = Off
↓
display_errors = On ←変更(エラーを表示する)

post_max_size = 8M

post_max_size = 20M ←変更(最大POSTアップロードサイズ)

;default_charset = "UTF-8"
↓
default_charset = "UTF-8" ←コメント解除(デフォルト文字コード)

upload_max_filesize = 2M
↓
upload_max_filesize = 20M ←変更(最大アップロードサイズ)

;date.timezone =
↓
date.timezone = Asia/Tokyo ←コメント解除&変更(タイムゾーン指定)

;mbstring.language = Japanese
↓
mbstring.language = Japanese ←コメント解除(デフォルト言語)

;mbstring.internal_encoding = EUC-JP
↓
mbstring.internal_encoding = UTF-8 ←コメント解除&変更(内部文字エンコーディングのデフォルト値)

;mbstring.http_input = UTF-8
↓
mbstring.http_input = UTF-8 ←コメント解除(HTTP入力文字エンコーディング)

;mbstring.http_output = SJIS
↓
mbstring.http_output = pass ←コメント解除&変更(HTTP出力文字エンコーディング)

;mbstring.encoding_translation = Off
↓
mbstring.encoding_translation = On ←コメント解除&変更(内部文字エンコーディングの有効・無効)

;mbstring.detect_order = auto
↓
mbstring.detect_order = auto ←コメント解除(文字コード検出のデフォルト値)

;mbstring.substitute_character = none;
↓
mbstring.substitute_character = none; ←コメント解除(無効な文字を代替する文字を定義)
Apache再起動
[root@centos ~]# systemctl restart httpd
PHP確認
[root@centos ~]# echo "<?php phpinfo(); ?>" > /var/www/html/info.php
ブラウザで確認 (http://www.ドメイン名/info.php にアクセス)

Home PageTop