nginx配置、域名、前端代码部署

服务器上部署nginx,部署多个独立的代码,用nginx做域名映射的配置方法:

  1. 修改/usr/local/nginx/conf/nginx.conf文件,重点是最后一行,include /data/nginx/conf/*vhost;
http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    include /data/nginx/conf/*vhost;
}

  2. 在/data/nginx/conf/ 目录下创建不同的配置文件

  3.配置对应的配置文件,以hw.keplermarket.cn.vhost为例

server{
    listen 80;
    server_name hw.keplermarket.cn;

    error_log   /data/nginx/logs/hw.keplermarket.cn/error.log;
    location / {
        root       /data/deploy/hw.keplermarket.cn/;
        access_log /data/nginx/logs/hw.keplermarket.cn/access.log main;
        try_files  $uri $uri/ /index.html;
    }
}

  4.放置发布的代码到对应的目录,例如 /data/deploy/hw.keplermarket.cn/ 下放置相应的代码

猜你喜欢

转载自www.cnblogs.com/yanghaifeng/p/10595032.html
今日推荐