linux build Nginx web page (compile and install)

♥️Author: Xiao Liu at Station C

♥️Personal homepage:  Xiao Liu’s homepage 

♥️Don’t let your body become crooked just because the road of life is bumpy; don’t let your pursuit be slow just because the journey of life is long.

♥️Learn the operation and maintenance experience accumulated over the past two years, as well as a full set of network experiment tutorials on the Cisco simulator. Column:Cloud Computing Technology

♥️Thank you CSDN for allowing you and me to meet!

What is Nginx?

Nginx (engine x) is a high-performance HTTP and Reverse proxyweb server, also provides IMAP/POP3/SMTP service. Nginx is the second most visited Rambler.ru site in RussiaRussia by Igor Sesoev ( Russian: Developed by Рамблер), the public version 1.19.6 was released on December 15, 2020. It releases thesource code under a BSD license Its stability, rich feature set, simpleconfiguration filesand lowsystem resources< a i=20> is famous for its consumption. On January 25, 2022, nginx 1.21.6 was released. Nginx is a lightweight Web server/reverse proxy Server andemail (IMAP/POP3) proxy server, in < Released under the /span> servers. webpage-like license. Its characteristics are that it occupies less memory and has strong concurrency capabilities. In fact, nginx's concurrency capabilities perform better among the same type of BSD

Table of contents

Benefits of Nginx

Nginx service description:

Build Nginx web page on linux

1. Required by the environment

2.Create program user

3. Compile and install Nginx

4.Web page production


Benefits of Nginx

A high-performance, lightweight Web service software
High stability
Low system resource consumption
High processing capability for HTTP concurrent connections
A single physical server can support 30,000~50,000 concurrent requests

Nginx service description:

Main configuration file:/usr/local/nginx/conf/nginx.conf
Check syntax: nginx -t
Start service: nginx< /span> Port number: tcp 80 Web page file: /usr/local /nginx/html/ Stop the service: killall -s QUIT nginx
Reload the service: killall -s HUP nginx


Build Nginx web page on linux

1. Required by the environment

The configuration and operation of Nginx require the support of software packages such as pcre and zlib. Therefore, the development packages (devel) of these software should be installed in advance to provide the corresponding libraries and header files to ensure that the installation of Ngix is ​​completed smoothly.

After the yum source configuration is completed, you can install pcre zlib (yum source images can be downloaded from the official websites of major manufacturers such as: Alibaba, Tsinghua, etc..)


2.Create program user

The Nginx service program runs as nobody by default. It is recommended to create a dedicated user account for it to more accurately control its access rights
, increase flexibility, and reduce security risks. For example, if you create a user named nginx, you will not be able to log in to the Shell environment without creating a host file
.

The -M option does not create a home directory for this user.

The -s option specifies that the user's shell is /sbin/nologin

/sbin/nologin is not a directory, it is an executable file that can be used as a shell but cannot be logged into the system.


3. Compile and install Nginx

When configuring Nginx compilation options, set the installation directory to /usr/local/nginx, and set the running user and group to nginx; enable the
http_stub_status_.module module to support status Statistics to facilitate viewing server connection information. Then perform make compilation and make install compilation and installation. The specific options of ./configure are determined according to actual needs. Before configuration, you can refer to the instructions given by "./configure --help".

After that, we make the nginx installation command available on the console. We need to link the nginx executable command to the user's local environment, that is, under /usr/local/sbin/. Use ls to check whether the link is successful.

At this point, you can use the nginx -t command to check the syntax of the configuration file so that the error location cannot be found.

Nginx’s default configuration file path/usr/local/nginx/conf/nginx.conf

Finally, just use nginx to start the service. It should be noted that if the server is already installed with other Web service software such as
httpd, you should modify the port, deactivate or uninstall it, etc. Measures to avoid port conflicts

You can check whether the service is enabled through the netstat command

4.Web page production

The web page file path is /usr/local/nginx/html/

You can modify index.html to write web pages. It ends here. Thank you for reading.

You should try your best to get through every hurdle in life. No matter what difficulties you encounter, never give up! ! !

Guess you like

Origin blog.csdn.net/lzl10211345/article/details/134644481