ubuntu系统中nginx配置问题

 Yang家联1 发布于 2022-10-28 00:35

本人昨天在阿里云租了一个服务器,选择的ubuntu server服务器。

后来安装了nginx,访问服务器IP,能出来“Welcome to nginx!”的字样,说明nginx安装启动没有问题。

后来我自定义配置了nginx.conf文件,主要是想改网站根目录。修改的nginx.conf如下:

我可以保证这个目录是没有问题的,如下图:

分割线----------------------------------------------------

但是,结果是,访问IP,出现了404错误!
无论是访问 http://120.25.238.160/index.html 还是 http://120.25.238.160/ 都是404错误。

这是为什么?
求解!!多谢!!

错误日志如下:

2 个回答
  • 你这么做是存在权限的问题的,nginx 是www-data用户,你网站根目录是是wfp所有,你还需要更改一个权限设置,
    我曾经遇到过这样的问题,我是这样做的并且认为这样做会更加安全

    huangyanxiong@huangyanxiong-Aspire-E1-471G:~/language/php/laravel$ id
    uid=1000(huangyanxiong) gid=1000(huangyanxiong) 组=1000(huangyanxiong),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)
    huangyanxiong@huangyanxiong-Aspire-E1-471G:~/language/php/laravel$ ps aux |grep nginx
    root      1292  0.0  0.0  85880  2880 ?        Ss   13:01   0:00 nginx: master process /usr/sbin/nginx
    huangya+  1298  0.0  0.0  86284  3512 ?        S    13:01   0:00 nginx: worker process
    huangya+  1299  0.0  0.0  86284  3512 ?        S    13:01   0:00 nginx: worker process
    huangya+  1300  0.0  0.0  86284  3512 ?        S    13:01   0:00 nginx: worker process
    huangya+  1301  0.0  0.0  86284  3512 ?        S    13:01   0:00 nginx: worker process
    huangya+  4778  0.0  0.0  15964  2200 pts/2    S+   13:44   0:00 grep --color=auto nginx
    huangyanxiong@huangyanxiong-Aspire-E1-471G:~/language/php/laravel$ ps aux |grep php-fpm
    root      1146  0.0  0.4 381444 29028 ?        Ss   13:01   0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)                    
    huangya+  1224  0.0  0.1 381444  8704 ?        S    13:01   0:00 php-fpm: pool www                                                       
    huangya+  1225  0.0  0.1 381444  8704 ?        S    13:01   0:00 php-fpm: pool www                                                       
    huangya+  4780  0.0  0.0  15964  2228 pts/2    S+   13:44   0:00 grep --color=auto php-fpm
    
    

    也就是网站根目录,nginx ,php-fpm 都使用同一个用户

    2022-10-29 06:39 回答
  • 原来root指向默认的目录,参考http://stackoverflow.com/questions/10674867/nginx-default-public-www-l...
    可能指向的是/usr/local/nginx/html;
    现在出现404错误,证明nginx还是能启动起来的,你可以确认一下/home/wfp/chatyou.net/website目录下有没有index.html文件。

    2022-10-29 06:40 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有