nginx解析php的配置

nginx解析php的配置

  • 配置如下:
location ~ \.php$
    {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php-fcgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www/test02$fastcgi_script_name;
    }
  • fastcgi_pass 用来指定php-fpm监听的地址或者socket
  • fastcgi_index index.php #设定访问根目录默认去找的文件
  • fastcgi_param SCRIPT_FILENAME /data/www/test02$fastcgi_script_name #设置访问根目录时默认寻找的文件

fastcgi_param SCRIPT_FILENAME /data/www/test02/abc$fastcgi_script_name #访问根目录www.test02.com/
会去默认寻找abc中index.php文件,而此时去访问这个index.php文件是寻找不到的只能通过根目录去访问
www.test02.com/abc/index.php 返回404

  • 查看/usr/local/php-fpm/etc/php-fpm.conf
pid = /usr/local/php-fpm/var/run/php-fpm.pid
error_log = /usr/local/php-fpm/var/log/php-fpm.log
[www]
listen = /tmp/php-fcgi.sock
;listen = 127.0.0.1:9000
listen.mode = 666
user = php-fpm
group =php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers =5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
  • 此文件设定了nginx 绑定的位置去给php-fpm解析

posted on 2018-01-08 00:18  游荡的鱼  阅读(9763)  评论(0编辑  收藏  举报

导航