Deploy multiple nginx on Linux server

The upgraded version 2.0 is about how to deploy multiple nginx on a Linux server. I have suffered a little before, so I will write this article to avoid repeating the same mistakes.


Preface

This article describes the deployment of installation packages in a Linux server intranet environment. Please read further if necessary. Feature this article to save time and effort. There are redundant parts, especially for novices.


以下是本篇文章正文内容

1. Download environment dependencies

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

Ninety percent of the images are available, so just wait until you run this command and wait for the download to complete. Just wait patiently. If the intranet access restriction level is high, you can go to the official website of each package to download the offline version, upload it, decompress it and use it. This part will depend on the follow-up feedback and consider whether to publish the next series of articles.

2. Install nginx

The installation of nginx here has changed from what I mentioned in my previous article, but the changes are not significant. I will describe the steps below.

1. Create a file where nginx is placed

Create the file nginx in the /usr/local directory, and name the two files nginx1 and nginx2 in the nginx folder.

2. Upload the decompressed compressed package

Download the genuine installation package on the nginx official website, be sure to download the genuine version! ! !
Pass the package into the server. Here I download one from nginx1 and one from nginx2. The reason why it is redundant is that this step can be optimized, but it is convenient for novices, so I will do it here first.
Unzip the compressed package

tar -zxvf xxx.tar.gz

Replace xxx with the actual package name.

Note that you must enter the corresponding directory when decompressing. If I decompress under the nginx1 folder, I will enter nginx1. If I want to decompress under the nginx2 folder, I will enter nginx2 and enter the command.

cd /usr/local/nginx/nginx1 
cd /usr/local/nginx/nginx2

3. Install nginx (key step)

Enter the nginx1 interface,

cd /usr/local/nginx/nginx/xxx

xxx unzipped the files for you

critical step

./configure  --prefix==/usr/local/nginx/nginx1/

Note that the Austrian path must be written correctly, this is your installation path

Wait slowly until the configuration is completed
and run

make

It is better to wait slowly until make is finished.

run

make install

Just wait for the installation to end. It is not recommended to make && make install. It is recommended to do it step by step;
so repeat the steps in the nginx2 directory. The only difference is the installation path

./configure  --prefix==/usr/local/nginx/nginx2/

3. Start nginx

/usr/local/nginx/nginx1/sbin/nginx -c /usr/local/nginx/nginx1/conf/nginx.conf
/usr/local/nginx/nginx2/sbin/nginx -c /usr/local/nginx/nginx2/conf/nginx.conf

After inputting, the response will be without error.

4. Verify whether nginx is started

ps -ef | grep nginx

As long as you see two main programs, it means that two nginx have been started.

Summarize

I hope it can help you. If it is useful, please like it. If you have any mistakes or doubts, please feel free to communicate with the blogger. If you don’t like it, please don’t comment.

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_51759592/article/details/132625889