因此,在进行了长时间的研究并且无法找到我的问题的答案之后,我决定寻求帮助。我最近以客户身份加入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.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。