1. Files required for nginx installation
1), nginx-1.2.8.tar.gz
2), openssl-1.0.1g.tar .gz
3), pcre-8.31.tar.gz
4), zlib-1.2.7.tar.gz
The download addresses of the above installation packages are available normally. , since I am using the installation package of the above version, the following installations are based on this.
2. Linux machine configuration environment
2.1.java environment
$java -version java version "1.8.0_45" java(tm) se runtime environment (build 1.8.0_45-b14) java hotspot(tm) 64-bit server vm (build 25.45-b02, mixed mode)
2.2.Hardware configuration
3. Installation steps
3.1. Unzip the installation package
Enter the nginx installation directory and unzip openssl-1.0.1g.tar.gz and pcre respectively -8.31.tar.gz, zlib-1.2.7.tar.gz, nginx-1.2.8.tar.gz four tar packages, execute the command tar -zxvf xxxx.tar.gz, where xxxx is the package name.
After decompression:
3.2. Compile the installation package
First compile the 3 required Library file packages: openssl-1.0.1g, pcre-8.31, zlib-1.2.7.
Compile openssl-1.0.1g, enter the file directory, and execute the following commands in sequence:
$./config$make$make install
Normal installation result:
Compile pcre-8.31, enter the file directory, and execute the following commands in sequence:
$./config $make $make install
Normal installation result:
Compile zlib-1.2.7, enter the file directory, and execute the following commands in sequence:
$./configure $make $make install
Normal installation results:
Next, Compile the nginx installation package, enter the file directory, and execute ./configure. You need to specify the installation directory –prefix=/opt/nginx/nginx and the path of the corresponding library file
sudo ./configure --prefix=/opt/nginx /nginx --with-openssl=/opt/nginx/openssl-1.0.1g --with-pcre=/opt/nginx/pcre-8.31 --with-zlib=/opt/nginx/zlib-1.2.7
Next, compile and install.
Copy code The code is as follows:
sudo ./configure --prefix=/opt/nginx/nginx --with-openssl=/opt/nginx/openssl-1.0.1g --with -pcre=/opt/nginx/pcre-8.31 --with-zlib=/opt/nginx/zlib-1.2.7
Next, compile and install.
$make
$make install
At this point, the nginx installation is completed.
3.3. Start nginx
Enter the nginx installation directory/opt/nginx/nginx/sbin and execute ./nginx to start the service.
[dddd.et15sqa /opt/nginx/nginx/sbin]
$sudo ./nginx
View the service process after startup:
$ps aux|grep nginx
root 2295 0.0 0.0 28264 804 ? ss 23:30 0:00 nginx: master process ./nginx
nobody 2296 0.0 0.0 28660 1356 ? s 23:30 0:00 nginx: worker process
125233 2411 0.0 0.0 113720 1012 pts/0 s 23:31 0:00 grep nginx
Open nginx default homepage:
#Service installation and startup OK!
4. Port forwarding
You need to forward port 80 to the tomcat homepage running in the server, and its port is 8080.
tomcat home page:
server { listen 80; server_name 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; #index index.html index.htm; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $remote_addr; proxy_pass http://127.0.0.1:8080; }Restart the nginx service, ./nginx -s reloadAt this time, you can access port 80, but it actually jumps to the service of port 8080.
The above is the detailed content of Nginx brief installation and configuration example analysis. For more information, please follow other related articles on the PHP Chinese website!

NGINX can be used to serve files and manage traffic. 1) Configure NGINX service static files: define the listening port and file directory. 2) Implement load balancing and traffic management: Use upstream module and cache policies to optimize performance.

NGINX is suitable for handling high concurrency and static content, while Apache is suitable for dynamic content and complex URL rewrites. 1.NGINX adopts an event-driven model, suitable for high concurrency. 2. Apache uses process or thread model, which is suitable for dynamic content. 3. NGINX configuration is simple, Apache configuration is complex but more flexible.

NGINX and Apache each have their own advantages, and the choice depends on the specific needs. 1.NGINX is suitable for high concurrency, with simple deployment, and configuration examples include virtual hosts and reverse proxy. 2. Apache is suitable for complex configurations and is equally simple to deploy. Configuration examples include virtual hosts and URL rewrites.

The purpose of NGINXUnit is to simplify the deployment and management of web applications. Its advantages include: 1) Supports multiple programming languages, such as Python, PHP, Go, Java and Node.js; 2) Provides dynamic configuration and automatic reloading functions; 3) manages application lifecycle through a unified API; 4) Adopt an asynchronous I/O model to support high concurrency and load balancing.

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.


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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

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),
