How to configure nginx so that certain domain names point to local directories?
phpcn_u1582
phpcn_u1582 2017-05-16 17:15:46
0
1
807

I am new to nginx and I don’t quite understand the terminology and configuration of the document. I would like to ask everyone here.

There is the following nginx configuration, and you want to point domain names such as my.domain.com to the local directory /usr/www/. I have reloaded the configuration file through nginx -s reload and still cannot point to the directory and display it when accessing http://my.domain.com.

server {
    listen       80;
    server_name  my.domain.com;
    index  index.html index.htm;
    
    autoindex on;
    autoindex_exact_size on;
    autoindex_localtime on;

    location / {
        root   /usr/www/;
    }
}

Try to replace the domain name with the real corresponding IP address, but it doesn't work either.

Of course it will take effect if server_name is set to localhost.

It has been ensured that the host does not redirect the domain name. (By the way, will nginx and host conflict, or does iginx have higher priority?)

phpcn_u1582
phpcn_u1582

reply all(1)
曾经蜡笔没有小新

In the hosts file, set my.domain.com to 127.0.0.1, and then configure it in nginx

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!