Simple way to install two Nginx under Linux

V Records 40,042 Views No comment

Here mainly introduces How to run 2 or more nginx on one server at the same time.May be written a bit general.

Install multiple Nginx at the same time

If you need to install two or more Nginx on one server, then we need to make settings at the time of installation.

When installing Nginx under Linux, it is usually required to set the installation path through the prefix during the ./configure phase. Therefore, you can install multiple nginx by specifying different prefixes in ./configure.

After the installation is complete, the two Nginx listening ports should be set to different listening ports. For example, 80, 81, otherwise one of the nginx will not start.

The first Nginx installation configuration

The second Nginx installation configuration

Modify the listening port of the first Nginx (80)

Modify the listening port of the second Nginx (81)

Add one more Nginx

Assume that an nginx has been installed automatically.

For example,The first Nginx directory is /usr/local/nginx

The second Nginx must be compiled and installed, you need to develop –prefix when compiling , Just like above.

Make a copy of the executable file:

Make a copy of the automatically installed startup script file,

Modify the startup script file /etc/init.d/nginx-new to point to the actual executable file /usr/local/nginx-new and modify other related options.

Modify the system configuration file (required by CentOS), /etc/sysconfig/nginx-new, change its contents to the actual configuration file address, NGINX_CONF_FILE=/usr/local/nginx-new/conf/nginx.conf

The last thing you need to remind is the two Nginx listening ports should be set to different listening ports.

This article was first published by V on 2018-10-09 and can be reprinted with permission, but please be sure to indicate the original link address of the article :

Leave a Reply

Your email address will not be published. Required fields are marked *