Nginx and replace the default port profile location

Foreword

Recently in preparation ready to graduate design, basically determined before and after the end of the separation of architecture, so we need to use the nginx.

Before nginx is placed on the docker, so there is no worry to change the port configuration with the configuration file. But now it is placed directly on the server, but with tomcat or port apollo clashed, so he moved to change the port as well as the idea of ​​the configuration file location.

text

nginx mounted in linux

sudo apt-get install nginx

Nginx After the installation is complete, the file will be in the directory / etc / nginx, the installation is somewhat similar with the docker.

Replace the nginx configuration profiles

(Actually not replace, be increased, configure it not so much trouble)

  • Modify / etc / nginx in nginx.conf
vim nginx.conf  --用vim打开文件
include /root/nginx/conf.d/*.conf;  -- 放在http块中,路径自定义切换
  • New folder and restart nginx
nginx -s reload

nginx replace the default port

  • Referring to modify the above changes to the configuration file, add a statement
include /etc/nginx/sites-enabled/*;  -- 默认有的,但是最好检查一下
  • modify the default file / etc / nginx / sites-enabled in
vim default  -- 用vim打开文件
listen 8091  default_server;    -- 修改监听端口
listen [::]:8091 default_server;  -- 修改监听端口
  • Restart nginx
nginx -s reload

Re-enter the ip with port will be able to see the effect, but if, like me ride on the server, remember to open the server port (small step on the pit I).

    This article first appeared in the cartoon's blog
     please indicate the source: https://cartoonyu.github.io/cartoon-blog/post/nginx/ replace nginx default configuration file location, and port /

Guess you like

Origin www.cnblogs.com/cartooon/p/12046620.html