Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos installation nginx tutorial

Shulou Source: shulou.com Published: 2022-06-03 05:49:28 09月21日 Update

1. Install dependent components

yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

2. Download the installation package

wget https://nginx.org/download/nginx-1.16.0.tar.gz

3. Compilation and installation

tar zxvf nginx-1.16.0.tar.gz

cd nginx-1.16.0

./ configure --prefix=/usr/local/nginx

make && make install

4, Start nginx service

cd /usr/local/nginx/sbin

./ nginx

5. Verify whether the service starts successfully

[root@localhost sbin]# netstat -ntlp | grep nginx

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 130245/nginx: master

6, Add nginx service

vi /lib/systemd/system/nginx.service

Document 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*

7, using systemd management

pkill nginx

systemctl start nginx

systemctl status nginx

Tags: Services success content files components administration compilation validation tutorials Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft MySQL Huawei macOS