PHP+NginXの一般的構築法

AWSのEC2を使用しています。

yum update
reboot

時間周り

cp -f /usr/share/zoneinfo/Japan /etc/localtime
vim /etc/rc.local
----------------------------------
cp -f /usr/share/zoneinfo/Japan /etc/localtime
----------------------------------

vim /etc/sysconfig/clock
----------------------------------
ZONE="Asia/Tokyo"
UTC=true
----------------------------------

ミドルインストール

yum install php54 php54-mysql php54-mbstring php54-xml php54-gd php54-mcrypt php54-pspell php54-pecl-imagick php54-pecl-apc php54-fpm php54-pecl-memcache php54-devel
yum install nginx mysql mysql-server
vim /etc/php.ini
----------------------------------
output_handler = mb_output_handler
error_log = /var/log/php/php.log
variables_order = "EGPCS"

upload_max_filesize = 8M

date.timezone = Asia/Tokyo

mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_character = none;
----------------------------------
mkdir /var/log/php
chmod 777 /var/log/php
vim /etc/php-fpm.d/www.conf
----------------------------------
;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/php-fpm.sock

; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
----------------------------------
chown nginx:root /var/log/php-fpm
service php-fpm start
vim /etc/nginx/nginx.conf
----------------------------------
    charset utf-8;
    root         /usr/share/nginx/html;

        location / {
          index index.php index.html index.htm;
        }

        location ~ \.php$ {
            root           html;
            #fastcgi_pass   127.0.0.1:9000;
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

----------------------------------
service nginx start