Nginxとphp-fomを使ってバーチャルホストを立ててみた
nginxでバーチャルホストを立てる
- 以下デフォルトの設定
/etc/nginx/conf.d/default.conf 〜〜(省略)〜〜 location ~ \.php$ { #root html; root ドキュメントルートのパス; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; 〜〜(省略)〜〜
- バーチャルホストの設定
- sudo vi /etc/nginx/conf.d/sample.conf(sample用のconfを作り設定を書いていく。cpして部分編集がスマートかもしれない)
server { listen 80; server_name centos65.sample; location / { root /var/www/html/sample; index index.php index.html index.htm; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html/sample/$fastcgi_script_name; include fastcgi_params; } }
参考元 http://qiita.com/alegriaghost/items/57f99539a3554b4fbd80