nginx relies on some software libraries. Before installation, please make sure that the system has software such as gcc, ssl, pcre, and gzip installed. You can use the rpm -q command to check whether the software is installed.
[root@redhat1 ~]# rpm -q gcc
gcc-4.1.2-44.el5
The dependent library information is as follows:
(1). The gzip module requires the zlib library
(2). The rewrite module requires the pcre library
(3). The ssl function requires the openssl library
If you install pcre , download pcre to the destination directory, the version selected here is pcre-8.38, after downloading, perform the following operations
tar -zxvf pcre-8.38.tar.gz cd pcre-8.38 ./configure make make install
Install nginx, execute the following command
By default In this case, the compiled and installed nginx already contains most of the available modules. You can set the usage of each module through the "./configure --help" option. For example, for the unnecessary http_ssi module, you can use "--without-http_ssi_module" " parameter to turn off this module; if you need the "http_perl" module, you can install this module through the "--with-http_perl_module" parameter. Perform the following steps to install.
tar -zxvf nginx-1.11.1.tar.gz cd nginx-1.11.1 ./configure --with-pcre=../pcre-8.38 --prefix=/usr/local/nginx make make install
To check whether the installation is successful, execute the following command
[root@redhat1 sbin]# cd /usr/local/nginx/sbin
[root@redhat1 sbin]# ./nginx -t
The following information appears to prove that the installation is successful
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Start nginx
[root@redhat1 sbin] # ./nginx
View port
[root@redhat1 sbin]# netstat -ntlp
The results are as follows:
proto recv-q send-q local address foreign address state pid/program name
tcp 0 0 127.0.0.1:2208 0.0.0.0:* listen 2993/hpiod
tcp 0 0 0.0.0.0 :834 0.0.0.0:* listen 2772/rpc.statd
tcp 0 0 0.0.0.0:11111 0.0.0.0:* listen 3391/ricci
tcp 0 0 0.0.0.0:111 0.0.0.0:* listen 2733/portmap
tcp 0 0 0.0.0.0:80 0.0.0.0:* listen 3852/nginx
tcp 0 0 0.0.0.0:16851 0.0.0 .0:* listen 3290/modclusterd
tcp 0 0 127.0 .0.1: 631 0.0.0.0:* Listen 3024/CUPSD
TCP 0 0 127.0.1:25 0.0.0.0:* Listen 3057/Sendmail: Acce
TCP 0 0 127.0.0.1:2207 0.0.0.0: * listen 2998/python
tcp 0 0 :::22 :::* listen 3013/sshd
You can also enter in the browser: http://localhost to verify whether the startup is successful. .
Stop nginx
The stop operation is performed by sending a signal to the nginx process
Step 1: Query the nginx master Process number:
ps -ef | grep nginx
Look for the master process in the process list. Its number is the main process number.
Step 2: Send signal
Stop nginx gracefully: kill -quit main process number
Quickly stop nginx: kill -term main Process number
Force to stop nginx: pkill -9 nginx
Restart nginx: smooth restart
If you change the configuration, you must restart nginx. You must first close nginx and then Open? No, you can send a signal to nginx to restart smoothly.
Smooth restart command:
kill -hup live name or process ID file path or /usr/local/nginx/sbin/nginx -s reload
Note, after modifying the configuration file, it is best to check whether the modified configuration file is correct to avoid nginx errors after restarting, which will affect the stable operation of the server. The command to determine whether the nginx configuration is correct is as follows:
nginx -t -c /usr/local/nginx/conf/nginx.conf or /usr/local/nginx/sbin /nginx -t
The above is the detailed content of Linux installation nginx server example code analysis. For more information, please follow other related articles on the PHP Chinese website!

NGINX started in 2002 and was developed by IgorSysoev to solve the C10k problem. 1.NGINX is a high-performance web server, an event-driven asynchronous architecture, suitable for high concurrency. 2. Provide advanced functions such as reverse proxy, load balancing and caching to improve system performance and reliability. 3. Optimization techniques include adjusting the number of worker processes, enabling Gzip compression, using HTTP/2 and security configuration.

The main architecture difference between NGINX and Apache is that NGINX adopts event-driven, asynchronous non-blocking model, while Apache uses process or thread model. 1) NGINX efficiently handles high-concurrent connections through event loops and I/O multiplexing mechanisms, suitable for static content and reverse proxy. 2) Apache adopts a multi-process or multi-threaded model, which is highly stable but has high resource consumption, and is suitable for scenarios where rich module expansion is required.

NGINX is suitable for handling high concurrent and static content, while Apache is suitable for complex configurations and dynamic content. 1. NGINX efficiently handles concurrent connections, suitable for high-traffic scenarios, but requires additional configuration when processing dynamic content. 2. Apache provides rich modules and flexible configurations, which are suitable for complex needs, but have poor high concurrency performance.

NGINX and Apache each have their own advantages and disadvantages, and the choice should be based on specific needs. 1.NGINX is suitable for high concurrency scenarios because of its asynchronous non-blocking architecture. 2. Apache is suitable for low-concurrency scenarios that require complex configurations, because of its modular design.

NGINXUnit is an open source application server that supports multiple programming languages and provides functions such as dynamic configuration, zero downtime updates and built-in load balancing. 1. Dynamic configuration: You can modify the configuration without restarting. 2. Multilingual support: compatible with Python, Go, Java, PHP, etc. 3. Zero downtime update: Supports application updates that do not interrupt services. 4. Built-in load balancing: Requests can be distributed to multiple application instances.

NGINXUnit is better than ApacheTomcat, Gunicorn and Node.js built-in HTTP servers, suitable for multilingual projects and dynamic configuration requirements. 1) Supports multiple programming languages, 2) Provides dynamic configuration reloading, 3) Built-in load balancing function, suitable for projects that require high scalability and reliability.

NGINXUnit improves application performance and manageability with its modular architecture and dynamic reconfiguration capabilities. 1) Modular design includes master processes, routers and application processes, supporting efficient management and expansion. 2) Dynamic reconfiguration allows seamless update of configuration at runtime, suitable for CI/CD environments. 3) Multilingual support is implemented through dynamic loading of language runtime, improving development flexibility. 4) High performance is achieved through event-driven models and asynchronous I/O, and remains efficient even under high concurrency. 5) Security is improved by isolating application processes and reducing the mutual influence between applications.

NGINXUnit can be used to deploy and manage applications in multiple languages. 1) Install NGINXUnit. 2) Configure it to run different types of applications such as Python and PHP. 3) Use its dynamic configuration function for application management. Through these steps, you can efficiently deploy and manage applications and improve project efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
