LoginSignup
20

More than 5 years have passed since last update.

CentOS + nginx + PHP環境でのnginxの設定めも

Last updated at Posted at 2014-09-27

自分用めも

yumでインストールしたもの

  • nginx
  • php関連
  • php-fpm

など

nginxでPHPスクリプトを実行させるための設定

メインの設定

/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;

〜〜(省略)〜〜

バーチャルホストの設定

/etc/nginx/conf.d/sample.conf
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;
    }
}

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20