我大约一个小时前刚刚安装了 nginx 和 php fastcgi,在阅读了快速启动配置的示例以及 nginx 文档等后,我只是无法让它工作。
无论我改变或尝试什么,我总是只得到“欢迎来到 Nginx!” “localhost/...”上的屏幕 - 我什至无法调用简单的index.html
我的配置:
(评论里的东西是我尝试过的)
// default nginx stuff (unchanged)
server {
#listen 80 default_server;
#listen 80 default;
listen 80;
#server_name localhost;
#server_name _;
#access_log /var/log/nginx/board.access_log;
#error_log /var/log/nginx/board.error_log;
#root /var/www/board;
#root /var/www/board/public/;
root /var/www/board/public;
#index index.html;
index index.html index.htm index.php;
}
如果我没理解错的话,这应该是最简单的设置了,对吧?只需定义
listen 80;
和 index index.html;
但我就是无法让它工作
文件 /var/www/board/public/index.html 存在并且有内容
在我再浪费 2 个小时尝试某件事之前,你们中的某个人可以快速观看一下并告诉我我做错了什么吗?谢谢。
从根本上来说,你没有声明 location,这是 nginx 用于将 URL 与资源绑定的地方。
server {
listen 80;
server_name localhost;
access_log logs/localhost.access.log main;
location / {
root /var/www/board/public;
index index.html index.htm index.php;
}
}
正文必须至少 30 个字符;您输入了 2。