Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 问题i';我和一个新的虚拟机在一起_Php_Nginx_Virtual Machine - Fatal编程技术网

Php 问题i';我和一个新的虚拟机在一起

Php 问题i';我和一个新的虚拟机在一起,php,nginx,virtual-machine,Php,Nginx,Virtual Machine,因此,在进行了一项长期的研究并没有找到问题的答案后,我决定寻求帮助。 我最近作为客户加入了DigitalOcean,并创建了我的第一个droplet,目的是从其他服务迁移。 它运行在Ubuntu18.04上,安装了Nginx和PHP7.2。 我一直在绞尽脑汁想弄明白为什么它不运行/var/www/html文件夹中的任何php文件,相反,我得到了一个简单的phpinfo()的“无法访问此站点”。 它运行html文件很好,所以它必须与php设置有关 它几乎总是简单的,但这次我似乎无法找出它是什么,有

因此,在进行了一项长期的研究并没有找到问题的答案后,我决定寻求帮助。 我最近作为客户加入了DigitalOcean,并创建了我的第一个droplet,目的是从其他服务迁移。 它运行在Ubuntu18.04上,安装了Nginx和PHP7.2。 我一直在绞尽脑汁想弄明白为什么它不运行/var/www/html文件夹中的任何php文件,相反,我得到了一个简单的phpinfo()的“无法访问此站点”。 它运行html文件很好,所以它必须与php设置有关

它几乎总是简单的,但这次我似乎无法找出它是什么,有人能帮助吗

以下是我的nginx默认配置:

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass PHP scripts to FastCGI server

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        # With php-cgi (or other tcp sockets):
        #fastcgi_pass 127.0.0.1:9000;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one

    location ~ /\.ht {
        deny all;
    }
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {
#       try_files $uri $uri/ =404;
#   }
#}
PHP似乎运行良好:

php7.2-fpm.service - The PHP 7.2 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.2-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-12-09 13:26:59 UTC; 30min ago
     Docs: man:php-fpm7.2(8)
 Main PID: 14842 (php-fpm7.2)
   Status: "Processes active: 0, idle: 2, Requests: 2, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 4704)
   CGroup: /system.slice/php7.2-fpm.service
           ├─14842 php-fpm: master process (/etc/php/7.2/fpm/php-fpm.conf)
           ├─14866 php-fpm: pool www
           └─14867 php-fpm: pool www

Dec 09 13:26:59 ubuntu-s-2vcpu-4gb-fra1-01 systemd[1]: Starting The PHP 7.2 FastCGI Process Manager...
Dec 09 13:26:59 ubuntu-s-2vcpu-4gb-fra1-01 systemd[1]: Started The PHP 7.2 FastCGI Process Manager.


使用
error\u log/var/log/nginx/error.log error打开错误日志,重新启动nginx,查看是否列出了任何内容。它不会显示与.php文件的页面加载问题相关的任何内容。