CentOS 7 installed nginx

CentOS 7 install Nginx

One, install dependency

# To install Nginx, you need to compile the source code downloaded from the official website. The compilation depends on the gcc environment. If there is no gcc environment, you need to install it. yum install -y gcc-c++# 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. yum install -y pcre pcre-devel# The zlib library provides many ways to compress and decompress. Nginx uses zlib to gzip the contents of the http package. yum install -y zlib zlib-devel# OpenSSL is a powerful secure socket layer cryptographic library, including the main cryptographic algorithms, commonly used key and certificate packaging management functions and SSL protocols, and provides a wealth of applications for testing or Use for other purposes. Nginx not only supports the http protocol, but also supports https (that is, HTTP is transmitted over the ssl protocol), so you need to install the OpenSSL library on Centos. yum install -y openssl openssl-devel

Second, Download and Decompress

# Official download page https://nginx.org/ en/download.html# Download wget https://nginx.org/download/nginx-1.16.0.tar.gz# Unzip tar -zxvf nginx-1.16.0.tar.gz

Three. Installation configuration

# Enter the directory# Use the default configuration./configure# Compile and install makemake install

Four. Use of Nginx

# Find the Nginx installation path whereis nginx# Enter the directory cd /usr/local/nginx/sbin/# Start./nginx# Force the end of the Nginx process ./nginx -s stop# Wait until the Nginx process finishes processing tasks and then stop. /nginx -s quit# Reload the configuration file./nginx -s reload# Nginx Startup Auto# Switch to the /lib/systemd/system/ directory and create nginx.service file cd /lib/systemd/system/vim nginx.service# The content of the file is as follows: [Unit]Description=nginx After=network.target [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginxExecReload =/usr/local/nginx/sbin/nginx reloadExecStop=/usr/local/nginx/sbin/nginx quitPrivateTmp=true [Install] WantedBy=multi-user.target# Exit and save the file, and execute the command to make Nginx start automatically systemctl enable nginx

Leave a Comment

Your email address will not be published.