Install necessary dependent plug-ins
yum install -y gcc gcc-c++ pcre \ pcre-devel zlib zlib-devel openssl openssl-devel wget
Create a folder and switch to it
mkdir /customer && cd /customer
Download the installation package (Similarly, if you want to install other versions, you can go to the official website link below and select the link for other versions Copy and replace)
wget https://nginx.org/download/nginx-1.16.0.tar.gz
Extract and install
tar zxvf nginx-1.16.0.tar.gz cd nginx-1.16.0 ./configure --prefix=/usr/local/nginx make && make install
Add global command
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
Test installation
nginx -v
As shown below, the installation is successful:
Verify whether the service is started successfully
netstat -ntlp | grep nginx
As follows:
Add nginx service
vim /lib/systemd/system/nginx.service
Insert the following content:
[unit] description=nginx after=network.target [service] type=forking execstart=/usr/local/nginx/sbin/nginx execreload=/usr/local/nginx/sbin/nginx -s reload execstop=/usr/local/nginx/sbin/nginx -s quit privatetmp=true [install] wantedby=multi-user.target
Start nginx as a service
pkill nginx systemctl start nginx
Check whether the service is started
systemctl status nginx netstat -ntlp | grep nginx
Configure the nginx service to start automatically at boot
systemctl enable nginx
The installation is now complete , the configuration file is at:
vim /usr/local/nginx/conf/nginx.conf
Optional:
The version number of nginx is open by default and can be viewed in the default error page and http response header.
Different versions, especially lower versions of nginx, may have vulnerabilities, so if you don’t want others to obtain the version number, you can choose to hide the version number.
Hide nginx version number
cd /usr/local/nginx/conf vim nginx.conf
Change the "server_tokens" of the nginx.conf file to "off":
http { ... server_tokens off; ... }
Modify fastcgi.conf
##vim fastcgi.conf
Modify the following lines
fastcgi_param server_software nginx/$nginx_version; # 改为: fastcgi_param server_software nginx;Restart nginx
systemctl restart nginx
The above is the detailed content of How to install Nginx1.16.0 under linux. For more information, please follow other related articles on the PHP Chinese website!

NGINXserveswebcontentandactsasareverseproxy,loadbalancer,andmore.1)ItefficientlyservesstaticcontentlikeHTMLandimages.2)Itfunctionsasareverseproxyandloadbalancer,distributingtrafficacrossservers.3)NGINXenhancesperformancethroughcaching.4)Itofferssecur

NGINXUnit simplifies application deployment with dynamic configuration and multilingual support. 1) Dynamic configuration can be modified without restarting the server. 2) Supports multiple programming languages, such as Python, PHP, and Java. 3) Adopt asynchronous non-blocking I/O model to improve high concurrency processing performance.

NGINX initially solved the C10K problem and has now developed into an all-rounder who handles load balancing, reverse proxying and API gateways. 1) It is well-known for event-driven and non-blocking architectures and is suitable for high concurrency. 2) NGINX can be used as an HTTP and reverse proxy server, supporting IMAP/POP3. 3) Its working principle is based on event-driven and asynchronous I/O models, improving performance. 4) Basic usage includes configuring virtual hosts and load balancing, and advanced usage involves complex load balancing and caching strategies. 5) Common errors include configuration syntax errors and permission issues, and debugging skills include using nginx-t command and stub_status module. 6) Performance optimization suggestions include adjusting worker parameters, using gzip compression and

Diagnosis and solutions for common errors of Nginx include: 1. View log files, 2. Adjust configuration files, 3. Optimize performance. By analyzing logs, adjusting timeout settings and optimizing cache and load balancing, errors such as 404, 502, 504 can be effectively resolved to improve website stability and performance.

NGINXUnitischosenfordeployingapplicationsduetoitsflexibility,easeofuse,andabilitytohandledynamicapplications.1)ItsupportsmultipleprogramminglanguageslikePython,PHP,Node.js,andJava.2)Itallowsdynamicreconfigurationwithoutdowntime.3)ItusesJSONforconfigu

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.


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

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

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

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
