[[nginx]]

*概要 [#dbc6d8d4]
nginxでPHPを動かす方法です。~
いくつかあるようですが、php-fpmでの方法を記載します。

*内容 [#i5b36c34]
***1.remiまたはepelのリポジトリを導入する。 [#ib0137b6]
***2.php-fpmをインストール [#jb55a762]
 # yum install php-fpm
 # php-fpm -v
 PHP 5.3.3 (fpm-fcgi) (built: Dec 11 2013 03:32:01)
 Copyright (c) 1997-2012 The PHP Group
 Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
 # /etc/init.d/php-fpm start
 php-fpm を起動中:                                          [  OK  ]
 # chkconfig php-fpm on
 # chkconfig php-fpm --list
 php-fpm        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

***3.nginxでphpをCGIとして稼働するように設定する。 [#n0f0059a]
 # cd /etc/nginx/conf.d/
 # vi server.conf
 以下のコメントアウトを解除
     #location ~ \.php$ {
     #    root           html;
     #    fastcgi_pass   127.0.0.1:9000;
     #    fastcgi_index  index.php;
     #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
     #    include        fastcgi_params;
     #}
	 
	 ↓
	 location ~ \.php$ {
         root           html;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  /ドキュメントルート$fastcgi_script_name;
         include        fastcgi_params;
     }
 	
 # /etc/init.d/nginx configtest
 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
 nginx: configuration file /etc/nginx/nginx.conf test is successful
 
 # service nginx restart

***4.テスト [#pd08ab79]
 # cd ドキュメントルート
 # vi phpinfo.php
 <?php
 phpinfo();
 ?>

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS