Home > Operation and Maintenance > Nginx > How to install and configure nginx under Centos7

How to install and configure nginx under Centos7

WBOY
Release: 2023-06-03 13:36:14
forward
1552 people have browsed it

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

(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 端口号
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template