CentOS + nginx + PHP环境下nginx配置的笔记

我的备忘录

通过yum安装的东西

    • nginx

 

    • php関連

 

    php-fpm

等等

为了使nginx执行PHP脚本,需要进行以下设置。

主要的设置

〜〜(省略)〜〜

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;

〜〜(省略)〜〜

虚拟主机的设置

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;
    }
}
广告
将在 10 秒后关闭
bannerAds