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

The method and steps of installing Nginx in CentOS7.2

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

Share

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

CentOS7.2 installation Nginx process notes, due to the need to learn, this time to learn a little "nginx". Learn about Nginx installation today and take notes

View the version of CentOS

Use the command to check the version of the current system

[root@localhost ~] # cat / etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)

Add a repository

To install Nginx on a CentOS system, you have to add a repository first, like this:

Vim / etc/yum.repos.d/nginx.repo

Use the vim command to open / etc/yum.repos.d/nginx.repo, if nginx.repo does not exist, create such a file, open it and press the small I key to enter edit mode, then copy and paste the following lines of code, press the esc key to exit when you are finished, and then type: wq (Save and exit)

[nginx] name=nginx repobaseurl= http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1

Yum command to install nginx

After completing the above, we can use the yum command to install nginx

Yum install nginx

Installation succeeded:

Loaded plugins: fastestmirror Langpacksnginx | 2.9kB 00:00 nginx/7/x86_64/primary_db | 14 kB 00:01 Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * extras: mirrors.btte.net * updates: mirrors.sina.cnResolving Dependencies-- > Running transaction check--- > Package nginx.x86_64 1nginx/7/x86_64/primary_db 1.10.1-1.el7.ngx will be installed-- > Finished Dependency ResolutionDependencies Resolved==== Package Arch Version Repository Size====Installing: nginx x86'64 1 kTransaction Summary====Install 1.10.1-1.el7.ngx nginx 640 kTransaction Summary====Install 1 PackageTotal download size: 640 kInstalled size: 2.1 MIs this ok [y/d/N]: yDownloading packages:nginx-1.10.1-1.el7.ngx.x86_64.rpm | 640 kB 00:27 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing: 1:nginx-1.10.1 -1.el7.ngx.x86_64 1 take 1-Thanks for using nginxreserved Please find the official documentation for nginx here:* http://nginx.org/en/docs/Commercial subscriptions for Nginx are available on:* http://nginx.com/products/---------------------------------------------------------------------- Verifying: 1:nginx-1.10.1-1.el7.ngx.x86_64 1 Installed: nginx .x86 _ 64 1 1.10.1-1.el7.ngx Complete!

Test the nginx profile

When you execute nginx-t, nginx tests the syntax of your configuration file and tells you if the configuration file is written correctly, as well as the path to the configuration file:

Nginx-t

Print as follows:

Nginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful

Indicates that the configuration file is successful!

Centos7.0+ nginx implements stop, start, restart

In CentOS7, you will find something like "systemctl." when you do the chkconfig command operation. Systemctl can simply realize the combination of service and chkconfig, so that you can achieve the function of two commands with one command.

The basic operation format of the systemctl command is:

Systemctl [OPTIONS...] {COMMAND}...

Take nginx service as an example, the actions to stop, start and restart are as follows:

Systemctl stop nginx.servicesystemctl start nginx.servicesystemctl restart nginx.service

Check service status

Systemctl status nginx.service

Enable the service to boot

Systemctl enable nginx.service

Cancel service boot and start

Systemctl disable nginx.service

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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