linux下nginx服务器域名指定目录

一般,域名指定ip之后,需要在ip所在的机器去指定相应站点的目录,否则域名会不起作用;

下面说说linux下的nginx服务器指定目录的细节:

域名绑定目录的配置文件都放到这里:  /usr/local/nginx/conf/vhost/

在改目录下,新建一个文件,命名:域名.conf; 如:www.baidu.com.conf

内容大概如下:

server
{
        listen       80;
        server_name  www.baidu.com;
        index index.html index.htm index.php;
        root  /var/www/html/homepage/;
        charset utf-8;
        location ~.*.(css|js|swf|jpg|gif|png|jpep|jpg|mp3|xx|xmlbak|xml)$ {
                expires       720h;
        }


        access_log off;

        location ~ .*.php$
        {
                include fcgi.conf;
                fastcgi_pass  127.0.0.1:8888;
                fastcgi_index index.php;
                expires off;
                access_log off;
              
        }
}

然后将你的网站内容放置到目录:/var/www/html/homepage/ 下面就行了;

原文地址:https://www.cnblogs.com/webStyle/p/4252402.html