PHP nginx 配置

本文介绍了如何配置PHP与Nginx,重点在于修改php.ini、php-fpm.conf以及nginx.conf文件,特别是将fastcgi_pass设置为unix socket,并解决了'No input file specified.'的错误,确保正确指定root目录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

php 配置 参考:

https://typecodes.com/web/php7configure.html

php.ini 是核心文件

php-fpm.conf    是php-fpm 配置文件

php.fpm.conf  最后引用了   php.fpm.d/www.conf

查看以上文件  得出: listen = /var/run/php5-fpm.sock。

 

 

配置nginx

编辑 nginx.conf  , 找到 location ~ \.php$ {  这一行 (一般配置文件都有示例)

 

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

        #}

修改   fastcgi_pass   unix:/var/run/php5-fpm.sock

重启nginx    ./sbin/nginx -s reload

打开网页:

如果出现:No input file specified.

查看 logs/error.log  可能是root  目录指定错误了

最后我的配置是:

server {

        listen    8080;

        server_name    localhost;

 

        root   /www/h5;

        index  index.html index.php;

 

        #location / {

         #   alias  /www/h5/;

          #  index  index.html;

            #autoindex on;      

       # }

 

        location ~ \.php$ {

            #root           html;

            #fastcgi_pass   127.0.0.1:9000;

            fastcgi_pass   unix:/dev/shm/php-cgi.sock;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            include        fastcgi_params;

            include        fastcgi.conf;

        }

 

 

    }

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值