Reference site https://www.rem-system.com/centos-nginx-inst/
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
# firewall-cmd --add-service=http --permanent
success
# firewall-cmd --reload
success
# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client http ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
To install nginx, you need to add a repository for nginx. Check the current repository file.
$ ls -s /etc/yum.repos.d/
total 48
4 CentOS-Base.repo 4 CentOS-Media.repo 4 epel.repo
4 CentOS-CR.repo 4 CentOS-Sources.repo 4 epel-testing.repo
4 CentOS-Debuginfo.repo 12 CentOS-Vault.repo
4 CentOS-fasttrack.repo 4 CentOS-x86_64-kernel.repo
Add the repository file for nginx to the above directory.
# vi /etc/yum.repos.d/nginx.repo
#Describe the following with reference to the official website
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
Make additional confirmations.
$ yum search nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ty1.mirror.newmediaexpress.com
* epel: ftp.iij.ad.jp
* extras: ty1.mirror.newmediaexpress.com
* updates: ty1.mirror.newmediaexpress.com
nginx | 2.9 kB 00:00
nginx/x86_64/primary_db | 186 kB 00:01
============================== N/S matched: nginx ==============================
collectd-nginx.x86_64 : Nginx plugin for collectd
munin-nginx.noarch : NGINX support for Munin resource monitoring
nginx-all-modules.noarch : A meta package that installs all available Nginx
: modules
nginx-debug.x86_64 : debug version of nginx
nginx-debuginfo.x86_64 : Debug information for package nginx
nginx-filesystem.noarch : The basic directory layout for the Nginx server
nginx-mod-http-image-filter.x86_64 : Nginx HTTP image filter module
nginx-mod-http-perl.x86_64 : Nginx HTTP perl module
nginx-mod-http-xslt-filter.x86_64 : Nginx XSLT module
nginx-mod-mail.x86_64 : Nginx mail modules
nginx-mod-stream.x86_64 : Nginx stream modules
nginx-module-geoip.x86_64 : nginx GeoIP dynamic modules
nginx-module-geoip-debuginfo.x86_64 : Debug information for package
: nginx-module-geoip
nginx-module-image-filter.x86_64 : nginx image filter dynamic module
nginx-module-image-filter-debuginfo.x86_64 : Debug information for package
: nginx-module-image-filter
nginx-module-njs.x86_64 : nginx njs dynamic modules
nginx-module-njs-debuginfo.x86_64 : Debug information for package
: nginx-module-njs
nginx-module-perl.x86_64 : nginx Perl dynamic module
nginx-module-perl-debuginfo.x86_64 : Debug information for package
: nginx-module-perl
nginx-module-xslt.x86_64 : nginx xslt dynamic module
nginx-module-xslt-debuginfo.x86_64 : Debug information for package
: nginx-module-xslt
nginx-nr-agent.noarch : New Relic agent for NGINX and NGINX Plus
owncloud-nginx.noarch : Nginx integration for ownCloud
pagure-web-nginx.noarch : Nginx configuration for Pagure
pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx
: Webserver
python2-certbot-nginx.noarch : The nginx plugin for certbot
sympa-nginx.x86_64 : Sympa with nginx
nginx.x86_64 : High performance web server
unit.x86_64 : NGINX Unit
unit-devel.x86_64 : NGINX Unit (development tools)
Name and summary matches only, use "search all" for everything.
By the way, the packages required for nginx installation are nginx.x86_64 : High performance web server is.
First, check the information of the nginx package.
$ yum info nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ty1.mirror.newmediaexpress.com
* epel: ftp.iij.ad.jp
* extras: ty1.mirror.newmediaexpress.com
* updates: ty1.mirror.newmediaexpress.com
Installed Packages
Name : nginx
Arch : x86_64
Epoch : 1
Version : 1.16.1
Release : 3.el7
Size : 1.6 M
Repo : installed
From repo : epel
Summary : A high performance web server and reverse proxy server
URL : http://nginx.org/
License : BSD
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP,
: POP3 and IMAP protocols, with a strong focus on high concurrency,
: performance and low memory usage.
Available Packages
Name : nginx
Arch : x86_64
Epoch : 1
Version : 1.19.5
Release : 1.el7.ngx
Size : 788 k
Repo : nginx/x86_64
Summary : High performance web server
URL : http://nginx.org/
License : 2-clause BSD-like license
Description : nginx [engine x] is an HTTP and reverse proxy server, as well as
: a mail proxy server.
Now install the nginx package.
#-You can omit the confirmation response during installation by adding the y option.(I did not know)
# yum -y install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 8.7 kB 00:00
* base: ty1.mirror.newmediaexpress.com
* epel: ftp.iij.ad.jp
* extras: ty1.mirror.newmediaexpress.com
* updates: ty1.mirror.newmediaexpress.com
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
nginx | 2.9 kB 00:00
updates | 2.9 kB 00:00
nginx/x86_64/primary_db | 186 kB 00:01
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.16.1-3.el7 will be updated
---> Package nginx.x86_64 1:1.19.5-1.el7.ngx will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
nginx x86_64 1:1.19.5-1.el7.ngx nginx 788 k
Transaction Summary
================================================================================
Upgrade 1 Package
Total download size: 788 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
nginx-1.19.5-1.el7.ngx.x86_64.rpm | 788 kB 00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 1:nginx-1.19.5-1.el7.ngx.x86_64 1/2
Cleanup : 1:nginx-1.16.1-3.el7.x86_64 2/2
Verifying : 1:nginx-1.19.5-1.el7.ngx.x86_64 1/2
Verifying : 1:nginx-1.16.1-3.el7.x86_64 2/2
Updated:
nginx.x86_64 1:1.19.5-1.el7.ngx
$ yum list installed | grep nginx
nginx.x86_64 1:1.19.5-1.el7.ngx @nginx
It was installed.
$ systemctl start nginx
#Check if it is running
$ systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2020-12-13 09:36:54 JST; 17s ago
Docs: http://nginx.org/en/docs/
Process: 30579 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 30580 (nginx)
CGroup: /system.slice/nginx.service
tq30580 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx....
mq30581 nginx: worker process
Dec 13 09:36:54 f5les1se systemd[1]: Starting nginx - high performance web .....
Dec 13 09:36:54 f5les1se systemd[1]: Can't open PID file /var/run/nginx.pid...ry
Dec 13 09:36:54 f5les1se systemd[1]: Started nginx - high performance web s...r.
Hint: Some lines were ellipsized, use -l to show in full.
Since it is Active: active (running), it is working normally. There seems to be another way to check the running process with the ps command.
$ ps -aux | grep nginx
root 30580 0.0 0.0 46492 972 ? Ss 09:36 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 30581 0.0 0.1 46884 1600 ? S 09:36 0:00 nginx: worker process
admin 30602 0.0 0.0 112812 972 pts/0 S+ 09:39 0:00 grep --color=auto nginx
Set nginx to start automatically when the servo is restarted. Again, use the systemctl command.
#enable on centOS means autostart
$ systemctl enable nginx
Make sure that it is set to start automatically.
$ systemctl is-enabled nginx
enabled
Since it is enabled, the setting is completed.
With the above procedure, you should be able to display the "web page" provided by default in the nginx package. Find the IP address of the server where you installed nginx from your web browser. Example: http://140.00.00.00
If the above screen is displayed, the setting is completed normally.
Recommended Posts