linux 下配置 虚拟域名

1.vim  /etc/hosts

2. 加入虚拟域名

 使用ifconfig 查看本机ip  如:127.0.0.1

   如:将www.imooc.com 反射到127.0.0.1 Ip地址下

  127.0.0.1  www.imooc.com 

  保存即可

3.在ngnix中加入www.imooc.com.conf配置文件

  

server {
     listen 80;
     autoindex on;
     server_name www.imooc.com;
     access_log /usr/local/nginx/logs/access.log combined;
     index index.html index.htm index.jsp index.php; #
     error_page 404 / 404.html;
     if ($query_string~ * ".*[\;'\<\>].*" ) {
         return 404;
     }
   
location / { proxy_pass http://127.0.0.1:8080;
add_header Access-Control-Allow-Origin *;
}
}

4:启动tomcat 、nginx

    启动nginx有时候会报  not found xxx.pid文件

   使用 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

  即可


5:访问即可

  


   

猜你喜欢

转载自blog.csdn.net/jackcheng1117/article/details/80204576