【PHP】php5導入

php5インストール

yum -y install php php-mbstring php-mysql

拡張モジュールはmbstringとmysqlの2つ。

php5設定

vi /etc/httpd/conf/httpd.conf
下記内容を変更
DirectoryIndex index.html index.html.var
↓
DirectoryIndex index.html index.htm index.cgi index.php

下記内容を追加(「AddType application/x-gzip .gz .tgz」の下)
AddType application/x-httpd-php .php
vi /etc/php.ini
short_open_tag = Off
↓
short_open_tag = On

expose_php = On
↓
expose_php = Off

max_execution_time = 30
↓
max_execution_time = 300

;default_charset = "iso-8859-1"
↓
default_charset = "UTF-8"

post_max_size = 8M
↓
post_max_size = 20M

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 = auto
↓
mbstring.http_input = UTF-8

;mbstring.http_output = SJIS
↓
mbstring.http_output = pass

;mbstring.encoding_translation = Off
↓
mbstring.encoding_translation = On

;mbstring.detect_order = auto
↓
mbstring.detect_order = auto

;mbstring.substitute_character = none;
↓
mbstring.substitute_character = none;
/etc/rc.d/init.d/httpd restart
  • php5の動作確認

    echo "<?php phpinfo(); ?>" > /var/www/html/info.php
    /etc/rc.d/init.d/iptables stop
    

    http://192.168.11.30/info.php

    php5の情報が表示されれば正常です。

    /etc/rc.d/init.d/iptables start
    rm -f /var/www/html/info.php