1. nginx installation environment
nginx is developed in C language and is recommended to be run on Linux. This tutorial uses Centos7 as the installation environment.
1.1 gcc
To install nginx, you need to compile the source code downloaded from the official website first. The compilation depends on the gcc environment. If there is no gcc environment, you need to install gcc: yum install gcc-c++
1.2 PCRE
PCRE (Perl Compatible Regular Expressions) is a Perl library, including a perl-compatible regular expression library. The http module of nginx uses pcre to parse regular expressions, so the pcre library needs to be installed on Linux.
yum install -y pcre pcre-devel
Note: pcre-devel is a secondary development library developed using pcre. nginx also requires this library.
1.3 zlib
The zlib library provides many compression and decompression methods. nginx uses zlib to gzip the contents of the http package, so the zlib library needs to be installed on Linux.
yum install -y zlib zlib-devel
1.4 openssl
OpenSSL is a powerful Secure Sockets Layer cryptographic library, including major Cryptographic algorithms, commonly used key and certificate encapsulation management functions and SSL protocols, and provides a wealth of applications for testing or other purposes.
nginx not only supports http protocol, but also supports https (that is, transmitting http over ssl protocol), so you need to install the openssl library on Linux.
yum install -y openssl openssl-devel
2. Compile and install
2.1 Official website download
Download .tar directly. gz installation package
2.2 Unzip
tar -zxvf nginx-1.12.1.tar.gz cd nginx-1.12.1
2.3 Configuration
Actually in nginx-1.10. In version 1, you don’t need to configure related things, the default is fine. Of course, it is also possible if you want to configure the directory yourself.
1. Use the default configuration (recommended)
./configure
2. Customize the configuration (not recommended)
Note: To specify the temporary file directory as /var/temp/nginx, you first need to create the temp and nginx directories under /var (/var/temp/nginx)
./configure \--prefix=/usr/local/nginx \--conf-path=/usr/local/nginx/conf/nginx.conf \--pid-path=/usr/local/nginx/conf/nginx.pid \--lock-path=/var/lock/nginx.lock \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--with-http_gzip_static_module \--http-client-body-temp-path=/var/temp/nginx/client \--http-proxy-temp-path=/var/temp/nginx/proxy \--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \--http-scgi-temp-path=/var/temp/nginx/scgi
3. Compile and install
make make install
After the compilation and installation are completed, you can view the installation path of nginx:
whereis nginx
4. Start and stop nginx
cd /usr/local/nginx/sbin/./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload ./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。 ./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
5. Query nginx process
ps aux|grep nginx
Restart nginx
1. Stop and then start (recommended):
Restarting nginx is equivalent to stopping and then starting, that is, executing first Stop command and then execute start command. As follows:
./nginx -s quit ./nginx
2. Reload the configuration file:
When the nginx configuration file nginx.conf is modified, a restart is required for the configuration to take effect. nginx, use -s reload to make the configuration information effective in nginx without first stopping ngin Corresponding to the IP address of the machine (such as: 192.168.1.121), you can see a page like this:
2.4 Auto-start at boot
That is, in rc.local Just add the startup code.
./nginx -s reload
Add a line to /usr/local/nginx/sbin/nginx
vim /etc/rc.localAt this point, nginx is installed, and the start, stop, and restart operations are also completed.
The above is the detailed content of JAVA--Example of how to install Nginx server under CentOS. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

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

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

Atom editor mac version download
The most popular open source editor

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