[英]Nginx does not execute php files on WSL. How can i fix this?
我在 Windows 10 上的 WSL(Linux 的 Windows 子系统)上使用 Ubuntu 18.04,我安装了 Nginx 和 php7.2-fpm 并创建了一个简单的 php 文件index.php
其中包含echo
语句内容。
我使用sudo php </directory/to/index.php>
来测试 php,因此它可以正常工作。 另外,当我启动 Nginx 并导航到localhost
,“欢迎使用 Nginx!” 页面显示。 但是,当我导航到服务器域时,浏览器会显示“无法访问此站点”。
我该如何解决这个问题?
server {
listen 80;
server_name site.local;
access_log /var/log/nginx/laragadgetstore.com.access.log main;
root /usr/share/nginx/html/site.local;
index index.php index.html index.htm index.nginx-debian.html;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_buffering off;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
}
location ~ /\.ht {
deny all;
}
}
在nginx.conf
,我将用户更改为 www-data 并在/etc/hosts
文件中将 127.0.0.1 定义为服务器域。 另外,我将 conf.d 和服务器域根目录的所有权更改为 www-data!
此外,在 Nginx 的error.log
文件中,最后一个错误是:
[emerg] 1837: io_setup() failed (38: Function not implemented)
仅当我重新启动 Nginx 时才会记录此错误。
我不知道该怎么做才能做到这一点!!
这对我有用。 我修改了下的默认文件
/etc/nginx/sites-available to use port 8081
代码:
server {
listen **8081** default_server;
listen [::]:**8081** default_server;
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.