nginx + php-fpm で PHP を動かす
nginx のインストールはコチラ
次に、php-fpmをインストールする
まずは remi Repository を追加する
$ sudo rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi $ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm $ wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm $ sudo rpm -ivh remi-release-6.rpm epel-release-6-7.noarch.rpm
php 関連をインストールする
$ sudo yum --enablerepo=remi install php php-fpm php-devel php-cli php-xml php-mysql php-mbstring php-gd $ php-fpm -v PHP 5.3.15 (fpm-fcgi) (built: Jul 20 2012 12:53:18) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologi
php-fpm を起動する
$ sudo /etc/init.d/php-fpm start
nginx の設定ファイルを編集する
$ cd /etc/nginx/conf.d $ sudo cp default.conf default.conf.org $ sudo vi default.conf
- default.conf
server {
listen 80 default_server;
server_name localhost;
#charset koi8-r;
charset utf-8;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}nginx を再起動する
$ sudo /etc/init.d/nginx restart