Linux system deployment Nginx detailed tutorial (graphic explanation)

Foreword: This blog records the complete process of how I deploy Nginx step by step using the Linux system.

Blogger's other deployment tutorials:

1. Jenkins deploys front-end and back-end separation projects: The most complete graphic tutorial for Jenkins deployment front-end and back-end separation projects (hands-on teaching)

2. Docker deploys front-end and back-end separation projects: deploy front-end and back-end separation projects through Docker (pro-test available)

3. Linux system deployment Tomcat: Linux system deployment Tomcat detailed tutorial (graphic explanation)

4. Linux system configuration Maven: Linux system configuration Maven environment detailed tutorial (graphic explanation)

5. Linux system configuration Node.js: Linux system configuration Node.js environment detailed tutorial (graphic explanation)

6. Linux system installation and deployment of MySQL: A complete tutorial on Linux system installation and deployment of MySQL (detailed explanation with pictures and texts)

7. Linux system installation and deployment of Redis: A complete tutorial on Linux system installation and deployment of Redis (detailed explanation with pictures and texts)

8. Linux system installation and deployment of MongoDB: A complete tutorial on Linux system installation and deployment of MongoDB (detailed explanation with pictures and texts)

9. Linux system installation and deployment of Jenkins: Linux system installation and deployment of Jenkins detailed tutorial (graphic explanation)

10. Pagoda panel deployment front-end separation project: Hands-on teaching using the pagoda panel deployment front-end separation project (full details)

Table of contents

1. Installation dependencies

2. Install Nginx

3. Configure Nginx

4. Release port number

5. Run Nginx

6. Project Gitee source code

7. Summary


1. Installation dependencies

yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl-devel

This command mainly includes the following:

1. gcc and gcc-c++-GNUC and C++ compilers: used to compile source code programs that depend on these two languages.

2. automake: A tool for generating Makefile files, used to compile source code through Makefile .

3. pcre and pcre-devel-Perl: Compatible regular expression libraries, many programs will rely on this library for regular matching.

4. zlib and zlib-devel: the zlib library and its development files that provide data compression functions .

5. openssl-devel: the development file of the OpenSSL library, which can provide functions such as encryption /SSL/TLS .

These are common dependencies when compiling source code. Without these packages, compiling source code that depends on them will fail. So usually if you want to compile and install software from source code on CentOS/RHEL, you need to install these compilation toolchains and library files in advance to ensure that the dependencies can be satisfied during compilation.

2. Install Nginx

1. I create a new nginx folder in the root directory to store the downloaded compressed package

mkdir nginx

2. Enter the directory

cd nginx

This is the absolute path of my directory 

3. Pull the compressed package directly from the Nginx official website

wget http://nginx.org/download/nginx-1.16.1.tar.gz

4. After the download is complete, unzip the

tar -zxvf nginx-1.16.1.tar.gz

5. Enter the directory we decompressed

cd nginx-1.16.1

6. Because I use the http protocol by default, I can directly execute the following command to compile

./configure

7. Installation

make && make install

This completes the installation!

3. Configure Nginx

1. View the root directory

whereis nginx

2. Enter the conf folder in the Nginx directory

cd /usr/local/nginx/conf

3. Use the vim editor to edit the nginx.conf file

vim nginx.conf

4. Press the i key on the keyboard to enter the editing mode

5. Change the port number 80 to port 88 (because mine is occupied), and then change the root path to the absolute path of the vue project package file, and do not change the others

Here I wrote a simple vue project by myself, and uploaded it to the Linux server as a dist folder. The absolute path is /project/vue/dist

6. Press the Esc key to exit the editing mode, enter: wq to save and exit the vim editor

This basic configuration is complete!

4. Release port number

Because we specified a new port number for the Nginx server above, my security group in HUAWEI CLOUD needs to allow port 88, otherwise I cannot access it.

5. Run Nginx

1. Enter the sbin directory in the root directory of Nginx

cd /usr/local/nginx/sbin

This file is used to start/stop Nginx

2. Start with the default configuration

./nginx

3. Enter http://ip address:88/ to access

In this way, the deployment is successful! 

4. Stop Nginx

./nginx -s stop

6. Project Gitee source code

Here I share the source code of the Vue project deployed above on my Gitee, if you are interested, you can take a look!

Source code address: Docker deploys Vue project: Use Docker to deploy a simple Vue project source code sharing

7. Summary

The above is my current explanation on how to deploy the Nginx server on the Linux system. If you have any questions, welcome to discuss in the comment area!

Guess you like

Origin blog.csdn.net/HJW_233/article/details/131808946