开发者社区> 问答> 正文

我在使用新VM时遇到的问题

因此,在进行了长时间的研究并且无法找到我的问题的答案之后,我决定寻求帮助。我最近以客户身份加入DigitalOcean,并创建了我的第一个Droplet,目的是从其他服务迁移。它运行在Ubuntu 18.04上,安装了Nginx和PHP 7.2。我一直在想找出为什么它不运行/ var / www / html文件夹中的任何php文件的想法,相反,我得到了一个简单的phpinfo()的“无法访问此站点”。它可以很好地运行html文件,因此它必须与php设置有关。

这几乎总是一件简单的事,但是这次我似乎无法弄清这是什么,有人可以提供帮助吗?

这是我对nginx的默认配置:

#
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似乎运行良好:

   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.

展开
收起
社区秘书 2019-12-10 10:27:56 510 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载