Home  >  Article  >  Operation and Maintenance  >  How to use yum to install nginx in centos8

How to use yum to install nginx in centos8

PHPz
PHPzforward
2023-05-29 08:37:051506browse

How to use yum to install nginx in centos8

centos8 Install nginx

yum directly install

centos8 and centos7Installing nginx is a little different. Centos8 comes with nginx 1.14.1. Let’s upgrade to the new stable version 1.20.1 first

Create the repo source file in the etc directory

cd /etc/yum.repos.d 
  touch nginx.repo

Use vim to edit

  vim nginx.repo

2. Copy the following content and save it using :wq

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

3. Check whether the source has been modified successfully

  yum info nginx

4. Install nginx

  yum install nginx -y

nginx basic commands

Use systemctl global process management, no need to go to sbin to start

# 开启 
systemctl start nginx

#停止
systemctl stop nginx

#重载nginx
systemctl reload nginx

Do not use systemctl, You can start nginx's sbin, and yum is installed in /usr/sbin

#切换到 /usr/sbin
cd /usr/sbin
# 开启 
 ./nginx  

#停止
./nginx -s stop

#重载nginx
./nginx -s reload

View nginx process status

ps -ef |grep nginx

The above is the detailed content of How to use yum to install nginx in centos8. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete