我正在一个水滴(数字海洋)中安装一个网站.我对正确安装带有PHP的NGINX有一个问题.我做了https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04个教程,但当我try 运行一些.php文件只是下载而已...

有什么 idea 吗?

-rw-r--r--  1 agitar_user www-data   418 Jul 31 18:27 index.php
-rw-r--r--  1 agitar_user www-data    21 Aug 31 11:20 info.php

我的/etc/nginx/site-可用/默认

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/html;
        index index.html index.htm index.php;

        # Make site accessible from http://localhost/
        server_name agitarycompartir.com;

               location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    ## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #
    #               # With php5-cgi alone:
    #               fastcgi_pass 127.0.0.1:9000;
    #               # With php5-fpm:
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_index index.php;
                    include fastcgi_params;
            }
  

              location / {
                    
                    try_files $uri $uri/ =404;
                    # Uncomment to enable naxsi on this location
                    # include /etc/nginx/naxsi.rules
            }

...

Others "location" are commented...

.

推荐答案

试试这个:

  1. Edit /etc/nginx/sites-available/default

  2. 取消对两条侦听线路的注释,使nginx在端口80 IPv4和IPv6上侦听

  3. 别管server_name

  4. index行上加index.php

  5. Uncomment location ~ \.php$ {}

    # pass the PHP scripts to FastCGI server listening on (...)
    #
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    
            # With php5-cgi alone:
            #fastcgi_pass 127.0.0.1:9000;
            # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
    
  6. Edit /etc/php5/fpm/php.ini and make sure cgi.fix_pathinfo is set to 0

  7. Restart nginx and php5-fpm sudo service nginx restart && sudo service php5-fpm restart


我一周前才开始使用Linux,所以我真的希望能在这方面帮助你.我正在使用nano文本编辑器编辑文件.如果没有,请运行apt get install nano.通过谷歌了解更多信息.

Php相关问答推荐

根据类别在WooCommerce中添加库存数量后缀

无法使用PHP DomDocument找到IMG元素

PHP Array to Powershell exec命令Args

使用PHP curl的Amazon SP API批处理调用

在PHP中读取JSON

将部分产品排除在WooCommerce的计算附加费之外

如何保存基于用户 Select 的复选框 Select 模式

WooCommerce短代码,显示特定产品的购物车徽章中的当前数量

允许客户定义特定WooCommerce产品的价格

在个人资料页面上显示个人资料图像

随机显示WordPress快捷代码功能时出现问题

AWS S3:当对象名称包含 % 时复制对象失败并出现错误 - 无效的复制源编码

如何在 Phpunit 的静态提供程序中创建测试双打?

在 WooCommerce 我的帐户自定义部分显示未购买的产品

加载 Xdebug PHP 7.4.0 失败

如何在 php 中获取正确的时间

添加或删除优惠券后自动刷新 WooCommerce checkout 表单字段

在 groupBy laravel 5.7 中 Select 多列

Laravel 10 单元测试看不到来自 Artisan Command 的数据库更改

使用 GROUP_CONCAT 规范化/转置来自查询的数据