开发者社区> 问答> 正文

新增网站nginx.conf配置问题


阿里云主机,现在运行了一个phpwind系统的网站。
我在www目录下新建了一个目录:abc,想作为新的站点,绑定域名:cdef.com  
在:/alidata/server/nginx/conf/vhosts目录中新建:abcdef.conf文件,文件代码如下:
server {
        listen       80;
        server_name  www.cdef.com cdef.com ;
    index index.html index.htm index.php;
    root /alidata/www/abc;
    location ~ .*\.(php|php5)?$
    {
        #fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires 30d;
    }
    location ~ .*\.(js|css)?$
    {
        expires 1h;
    }
    #伪静态规则
    include /alidata/server/nginx/conf/rewrite/default.conf;
    log_format  abc  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /alidata/log/nginx/access/default.log abc;
}

以上是根据官方帮助中心的提示做的,但是在访问网站的时候,网站打不开,网站目录中有index.html文件。


请各位高手帮我看看。

展开
收起
ap0839m1k 2016-01-08 15:00:54 6437 0
4 条回答
写回答
取消 提交回答
  • 回 楼主ap0839m1k的帖子
    你配置一个静态的页面看是否可以正常访问,如果可以的话就可能是php程序解析的问题
    2016-01-11 13:21:16
    赞同 展开评论 打赏
  • Re新增网站nginx.conf配置问题
    你访问的是PHP动态页面,不知道你有没有开启fpm模块!
    2016-01-11 11:14:37
    赞同 展开评论 打赏
  • 回 1楼dongshan8的帖子

    版主你好,我重新启动云主机了。nginx也应该重启了吧。

    现在输入网址直接下载一个文件,用记事本打开是以下代码:
    <?php
    require(dirname(__FILE__)."/do/main.php");
    ?>

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

    回 1楼dongshan8的帖子
    [root@AY1207220849151896269 sbin]# nginx -s reload
    nginx: [warn] the "log_format" directive may be used only on "http" level in /alidata/server/nginx/conf/vhosts/default±¸·ۮconf:25
    nginx: [warn] the "log_format" directive may be used only on "http" level in /alidata/server/nginx/conf/vhosts/linda.conf:25
    nginx: [warn] the "log_format" directive may be used only on "http" level in /alidata/server/nginx/conf/vhosts/phpwind.conf:25
    nginx: [emerg] duplicate "log_format" name "phpwind" in /alidata/server/nginx/conf/vhosts/phpwind.conf:25
    [root@AY1207220849151896269 sbin]#
    2016-01-08 16:50:02
    赞同 展开评论 打赏
  • 旺旺:nectar2。
    楼主您好,

    请问您新增加站点的配置文件后,有没有重启nginx的服务?

    您新增的 abcdef.conf 文件,有没有被 nginx 服务读取使用呢?

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

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

    如果浏览器访问php后缀的文件会自动下载,那可能是nginx的配置文件设置不正确。

    建议多检查nginx的配置文件。
    2016-01-08 15:37:42
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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