nginxでphpを動かす(php-fpmをyumでインストール)
CentOS+nginxの環境でPHPを動かす設定をしてみました。
※下記のようにyumでインストールするにはPHP5.3以上が必須です。
・リポジトリを登録
※versionは最新を確認して使用する。
epel
# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
remi
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
・yumでインストール
# yum -y install php-cli php-fpm php-mbstring --enablerepo=remi
設定ファイル
/etc/php-fpm.conf
/etc/php-fpm.d/www.conf
・php-fpm起動
# /etc/init.d/php-fpm start
・自動起動設定
# chkconfig php-fpm on # chkconfig --list php-fpm php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
・nginx設定
# vi /etc/nginx/nginx.conf htttp { server { listen 80; server_name test.com; index index.html index.php index.htm; root /usr/share/nginx/html; charset utf-8; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
・nginx再起動
# /etc/init.d/nginx restart