Home  >  Q&A  >  body text

yaf - linux下nginx解析本地虚拟域名

配置yaf框架的时候,发现得配置一个虚拟域名。
于是在/etc/hosts增加了一个本地域名127.0.0.1 www.abc.com
nginx/config/vhost目录下增加一个虚拟主机文件'www.abc.com`;

server
        {
                listen 80;
                #listen [::]:80;
                server_name www.abc.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /home/wwwroor/www.abc.com/public;

                include none.conf;
                #error_page   404   /404.html;
                location ~ [^/]\.php(/|$)
                        {
                                # comment try_files $uri =404; to enable pathinfo
                                try_files $uri =404;
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fastcgi.conf;
                                #include pathinfo.conf;
                        }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

                access_log off;
        }

但是每次访问www.abc.com的时候,访问的都是wwwroot这个web根目录。
怎么让它进入/home/wwwroor/www.abc.com/public这个目录啊?

阿神阿神2765 days ago480

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 13:26:57

    Already solved. There is no problem with the configuration, but the configuration file under vhost is missing the .conf suffix. Alas, I made the same mistake for the second time, so this should be used as a record backup.

    reply
    0
  • 迷茫

    迷茫2017-04-17 13:26:57

    Please confirm whether your configuration file www.abc.com has been loaded successfully and whether the content is correct. The judgment method is very simple, enter an incorrect content in this configuration file, and then execute nginx -t.

    Because it can be seen from the description of the topic, www.abc.com This file should be referenced by nginx’s main configuration file (include), and should be loaded through wildcard. This may result in unsuccessful loading.

    Please observe the output, for example:

    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    

    means that the configuration file /etc/nginx/nginx.conf is loaded and there are no errors.

    reply
    0
  • Cancelreply