How to install Nginx with YUM in CentOS7 system

10-30-2023

brief introduction

Nginx was developed by igor sysoev for rambler.ru, the second most visited site in Russia, and the first public version 0.1.0 was released on October 4th, 2004. It publishes the source code in the form of bsd-like license, and is famous for its stability, rich feature set, sample configuration file and low system resource consumption.

Centos 7 condition

The steps in the tutorial require root privileges.

1. add nginx to yum source

Add the centos 7 nginx yum repository, open the terminal, and use the following command:

sudo rpm -uvh http://nginx.org/packages/centos/7/noarch/rpms/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Second, install nginx

Use yum command in your centos 7 server to get from nginx source server to install nginx:

sudo yum install -y nginx

Nginx will be installed in your centos 7 server.

Third, start nginx

The newly installed nginx will not start by itself. Run nginx:

sudo systemctl start nginx.service

If all goes well, now you can visit your web page through your domain name or ip to preview nginx's default page;

If you see this page, it means that the web server in your centos 7 has been installed correctly.

Centos 7 boot nginx

sudo systemctl enable nginx.service

Nginx configuration information

Default directory where website files are stored.

/usr/share/nginx/html

Default site configuration of website

/etc/nginx/conf.d/default.conf

Customize nginx site configuration file storage directory.

/etc/nginx/conf.d/

Nginx global configuration

/etc/nginx/nginx.conf

Here you can change the settings for users to run nginx daemon processes, and the number of worker processes gets that nginx is running, and so on.

Linux view public network ip

You can run the following command to display the public ip address of your server:

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's//.*$//'

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us