Home > Article > Operation and Maintenance > How to install and configure nginx under Centos7
Note: The basic directory path for software installation: /usr/local, so when downloading the software, switch to this directory to download and unzip it directly
1. Install gcc gcc-c dependency package
yum install -y gcc gcc-c
2. Download, compile and install the pcre library
Switch to usr Execute the command in the /local directory
Download the installation package
wget
Decompress the installation package
tar -zxvf pcre-8.36.tar.gz
Compile and install
cd pcre-8.36 ./configure make && make install
3. Download, compile and install the ssl library
Download the installation package
wget
Unzip the compressed package
tar -zxvf openssl-1.0.1j.tar.gz
Compile and install
cd openssl-1.0.1j ./config make && make install
4. Download, compile and install the zlib dependent library
Download the installation package
wget
Unzip the installation package
tar -zxvf zlib-1.2. 11.tar.gz<br>
Compile and install
cd zlib-1.2.11 ./configure make && make install
After the dependent packages and environment are installed and configured, you need to install nginx
5.nginx installation
Download the installation package
wget
Unzip the installation package
tar -zxvf nginx-1.8.0.tar .gz
Compile and install
cd nginx-1.8.0 ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module make && make install
(Note: In the second instruction of compilation: --prefix=/usr/local/nginx specifies the directory for compilation and installation. After the compilation is successful, it will Display the nginx installation folder in the /usr/local directory, you can delete the nginx-1.8.0 compiled file)
6.nginx related operation commands
Switch to In the nginx directory
cd /usr/local/nginx
Execute the following command
Start nginx
./ sbin/nginx
Check whether the nginx configuration file is correct
./sbin/nginx -t
See the instructions as shown in the figure The nginx configuration file is accurate
Stop nginx
Check the process number occupied by nginx and end it
ps -ef|grep nginx kill -9 端口号
The above is the detailed content of How to install and configure nginx under Centos7. For more information, please follow other related articles on the PHP Chinese website!