Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS configures Nginx's official Yum source

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Since we don't have the nginx we want in the yum source, we need to create a "/ etc/yum.repos.d/nginx.repo" file, which is actually a new yum source.

[root@niaoyun~] # vim / etc/yum.repos.d/nginx.repo

Then copy the following:

[nginx]

Name=nginx repo

Baseurl= http://nginx.org/packages/centos/$releasever/$basearch/

Gpgcheck=0

Enabled=1

Then after saving the "/ etc/yum.repos.d/nginx.repo" file, we use the yum command to check whether our nginx's yum source is configured.

[root@niaoyun~] # yum list | grep nginx

Nginx.x86_64 1purl 1.10.1-1.el7.ngx nginx

Nginx-debug.x86_64 1purl 1.8.0-1.el7.ngx nginx

Nginx-debuginfo.x86_64 1purl 1.10.1-1.el7.ngx nginx

Nginx-module-geoip.x86_64 1purl 1.10.1-1.el7.ngx nginx

Nginx-module-p_w_picpath-filter.x86_64 1purl 1.10.1-1.el7.ngx nginx

Nginx-module-njs.x86_64 1:1.10.1.0.0.20160414.1c50334fbea6-1.el7.ngx

Nginx

Nginx-module-perl.x86_64 1purl 1.10.1-1.el7.ngx nginx

Nginx-module-xslt.x86_64 1purl 1.10.1-1.el7.ngx nginx

Nginx-nr-agent.noarch 2.0.0-9.el7.ngx nginx

Pcp-pmda-nginx.x86_64 3.10.6-2.el7 base

If the command is displayed like this, then the yum source for our nginx is configured successfully!

Then to install our nginx, execute it directly:

[root@niaoyun~] # yum-y install nginx

If the operation is correct, the nginx environment has already installed OK.

Of course, you can also use the command to find out if the installation is complete.

[root@niaoyun~] # rpm-Q nginx

Nginx-1.10.1-1.el7.ngx.x86_64

No, it has been successful, and it is the latest official version of nginx.

-

Case 2:

1. Add Nginx to the 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.rpm2. Install Nginx

Use the yum command from your CentOS 7 server to get it from the Nginx source server to install Nginx:

Sudo yum install-y nginx

Nginx will be installed on your CentOS 7 server.

3. Start Nginx

The newly installed Nginx will not start on its own. 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 the default page of Nginx

If you see this page, then your CentOS 7 web server has been installed correctly.

Power on CentOS 7 and start Nginxsudo systemctl enable nginx.service

For more systemctl commands, see "systemctl Command usage"

Nginx configuration Information

The default directory for storing website files

/ usr/share/nginx/html

Site default site configuration

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

Customize the Nginx site configuration file storage directory

/ etc/nginx/conf.d/

Nginx global configuration

/ etc/nginx/nginx.conf

Nginx start

Nginx-c nginx.conf

Here you can change the settings for the user to run the Nginx daemon process, and the number of worker processes to get the Nginx running, and so on.

Linux views 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 /. * $/ /'

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report