开发者社区> 问答> 正文

IP访问正常用网址访问显示403 Forbidden nginx/1.4.4

操作系统: Aliyun Linux 5.7 64位地域: 美西 1
域名:gift为后缀的域名
无备案


根据阿里云视频课程<零基础实现在阿里云ECS上建立WordPress站点>进行安装
视频课程地址: https://www.aliyun.com/support/video/list?spm=5176.7972478.234816.5.HNLPTW


然后根据<Nginx绑定多个域名的方法>中第一个方法进行域名的绑定
网址: https://help.aliyun.com/knowledge_detail/6671603.html?spm=5176.100241.yqaskinfo1.3.48egXx
对其中的一些地方进行了修改,然后重启


修改1:
教程的配置文件存放目录为:  /usr/local/nginx/conf/servers
我的配置文件存放目录为:     /alidata/server/nginx-1.4.4/conf/vhosts


修改2:
教程的网站根目录:  root /home/www/server***.com;  
我的网站根目录:     alidata/www/server***.com;  


然后用IP进行访问,访问正常,如下图








然后用网址进行访问,访问结果如图





展开
收起
first_principle 2016-07-03 13:24:22 17663 0
2 条回答
写回答
取消 提交回答
  • 回 1楼dongshan8的帖子
    感谢你的解答!


    之后我将文件<www.artificialintelligence.gift.conf>中的内容修改如下

    server
    {
    listen  80;
    server_name www.artificialintelligence.gift;
    index index.htm index.html index.php;
    root /alidata/www/artificialintelligence.gift/wordpress;
    include location.conf;
    }

    采用重启nginx命令1:  /etc/init.d/nginx restart
    结果为
    [root@iZu1b3d2npoZ vhosts]# :/etc/init.d/nginx restart
    -bash: :/etc/init.d/nginx: No such file or directory


    采用重启nginx命令2:  service nginx reload
    结果为:
    [root@iZu1b3d2npoZ vhosts]#  service nginx reload
    Reloading nginx!nginx: [emerg] open() "/alidata/server/nginx/conf/location.conf" failed (2: No such file or directory) in /alidata/server/nginx/conf/vhosts/www.artificialintelligence.gift.conf:7

      
    备注:文件<www.artificialintelligence.gift.conf>之前是我在电脑上面编写好,通过Xftp上传上去的,这个文件的颜色为白色,与其他文件的颜色不一致,我怀疑这里是不是会有问题





    -------------------------

    回 3楼dongshan8的帖子
    非常感谢你一直无私的解答
    按照要求将站点配置文件( www.artificialintelligence.gift.conf)里的"include location.conf;"删除后,重启nginx情况如下

    [root@iZu1b3d2npoZ vhosts]# service nginx reloada
    Usage: nginx {start|stop|restart|reload|help}
    [root@iZu1b3d2npoZ vhosts]# /etc/init.d/nginx restart
    Stopping nginx!
    Starting nginx!
    [root@iZu1b3d2npoZ vhosts]# /etc/init.d/nginx restart
    Stopping nginx!
    nginx already running....
    [root@iZu1b3d2npoZ vhosts]#

    然后
    http://www.artificialintelligence.gift/
    http://www.artificialintelligence.gift/wordpress/
    这两个站点都不开,显示结果如下


    望能解答!
    2016-07-03 19:38:23
    赞同 展开评论 打赏
  • 旺旺:nectar2。
    楼主您好,

    看您的描述,换成这个网址,应该是可以访问到wordpress站点内容的: http://artificialintelligence.gift/wordpress/

    或许您将站点的目录文件路径修改为:root /alidata/www/server***.com/wordpress;

    之后才可以直接输入域名后(不用加/wordpress),访问到网站内容。



    -------------------------

    回 2楼(first_principle) 的帖子
    您好,

    可将站点配置文件( www.artificialintelligence.gift.conf)里的这一行删除后再试试 。

    include location.conf;



    -------------------------

    回 4楼(first_principle) 的帖子
    您好,

    上图显示,可能您的nginx没有在80端口监听,所以不能访问到web内容了。

    我不确定是否因为删除掉location.conf文件的引用后造成的,我先从头为您在测试机里测试一下吧。您用的是“Linux一键安装包”吗?

    为您查看了绑定域名的教程,里边有写 location.conf 并不是必须引用的配置文件: https://help.aliyun.com/knowledge_detail/6671603.html

    所以,或许您可以尝试重启一下ECS,看看80的Web端口访问是否能恢复正常。

    2016-07-03 15:51:31
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载