• Nginx虚拟主机


    [root@Nginx-server ~]# tar zxvf nginx-1.11.2.tar.gz

    [root@Nginx-server ~]# useradd -M -s /sbin/nologin nginx
    [root@Nginx-server ~]# cd nginx-1.11.2
    [root@Nginx-server nginx-1.11.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module

    [root@Nginx-server nginx-1.11.2]# make && make install 

    [root@Nginx-server nginx-1.11.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
    [root@Nginx-server nginx-1.11.2]# nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    [root@Nginx-server nginx-1.11.2]# nginx

    [root@Nginx-server nginx-1.11.2]# cd /usr/local/nginx/conf/

    [root@Nginx-server conf]# sed -i '$iinclude vhosts/*;' nginx.conf

    [root@Nginx-server conf]## grep -vE "#|^$" /usr/local/nginx/conf/nginx.conf
    worker_processes 1;
    events {
    worker_connections 1024;
    }
    http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    server {
    listen 80;
    server_name localhost;
    location / {
    root html;
    index index.html index.htm;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }
    }
    include vhosts/*;
    }

    [root@Nginx-server conf]## mkdir /usr/local/nginx/conf/vhosts/       #创建虚拟主机的的专属目录vhosts;

    [root@Nginx-server conf]# vim /usr/local/nginx/conf/vhosts/www.xiaoyu.com

    server {
    listen 80;
    server_name www.xiaoyu.com;
    location / {
    root /usr/local/nginx/html/www.xiaoyu.com/;
    index index.html index.htm;
    }

    expires 3d;

    }

    root@Nginx-server ~]# vim /usr/local/nginx/conf/vhosts/www.hexun.net

    server {
    listen 80;
    server_name www.hexun.net;
    location / {
    root /usr/local/nginx/html/www.hexun.net/;
    index index.html index.htm;
    }

    expires 3d;
    }

    [root@Nginx-server ~]# mkdir /usr/local/nginx/html/wwww.xiaoyu.com -p     #创建对应虚拟主机xiaoyu的网站根目录,hexun.net亦是如此,网页内容区分开即可
    [root@Nginx-server ~]# cd /usr/local/nginx/html/wwww.xiaoyu.com/
    [root@Nginx-server wwww.xiaoyu.com]# ls
    [root@Nginx-server wwww.xiaoyu.com]# echo "This is xiaoyu website" > index.html

     配置完成之后验证即可

  • 相关阅读:
    9.17
    9.14
    9.13
    9.13
    9.11
    9.28
    10 .19 知识点
    redux
    react路由
    react的三大属性
  • 原文地址:https://www.cnblogs.com/bixiaoyu/p/8253707.html
Copyright © 2020-2023  润新知