ENV:
[root@centos7 ~]# uname -r
3.10.0-514.el7.x86_64
[root@centos7 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
安装nginx源:
[root@centos7 ~]# rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Retrieving http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
warning: /var/tmp/rpm-tmp.DdFn2k: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nginx-release-centos-7-0.el7.ngx ################################# [100%]
直接yum install -y nginx安装:
[root@centos7 ~]# yum install -y nginx
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirror.lzu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.16.0-1.el7.ngx will be installed
--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: 1:nginx-1.16.0-1.el7.ngx.x86_64
--> Running transaction check
---> Package openssl-libs.x86_64 1:1.0.1e-60.el7 will be updated
--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-60.el7 for package: 1:openssl-1.0.1e-60.el7.x86_64
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update
--> Running transaction check
---> Package openssl.x86_64 1:1.0.1e-60.el7 will be updated
---> Package openssl.x86_64 1:1.0.2k-16.el7_6.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
nginx x86_64 1:1.16.0-1.el7.ngx nginx 766 k
Updating for dependencies:
openssl x86_64 1:1.0.2k-16.el7_6.1 updates 493 k
openssl-libs x86_64 1:1.0.2k-16.el7_6.1 updates 1.2 M
Transaction Summary
================================================================================
Install 1 Package
Upgrade ( 2 Dependent packages)
Total download size: 2.4 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/openssl-1.0.2k-16.el7_6.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for openssl-1.0.2k-16.el7_6.1.x86_64.rpm is not installed
(1/3): openssl-1.0.2k-16.el7_6.1.x86_64.rpm | 493 kB 00:50
(2/3): openssl-libs-1.0.2k-16.el7_6.1.x86_64.rpm | 1.2 MB 01:21
(3/3): nginx-1.16.0-1.el7.ngx.x86_64.rpm | 766 kB 02:40
--------------------------------------------------------------------------------
Total 15 kB/s | 2.4 MB 02:40
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-3.1611.el7.centos.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Updating : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 1/5
Updating : 1:openssl-1.0.2k-16.el7_6.1.x86_64 2/5
Installing : 1:nginx-1.16.0-1.el7.ngx.x86_64 3/5
----------------------------------------------------------------------
Thanks for using nginx!
Please find the official documentation for nginx here:
* http://nginx.org/en/docs/
Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.html
Commercial subscriptions for nginx are available on:
* http://nginx.com/products/
----------------------------------------------------------------------
Cleanup : 1:openssl-1.0.1e-60.el7.x86_64 4/5
Cleanup : 1:openssl-libs-1.0.1e-60.el7.x86_64 5/5
Verifying : 1:nginx-1.16.0-1.el7.ngx.x86_64 1/5
Verifying : 1:openssl-1.0.2k-16.el7_6.1.x86_64 2/5
Verifying : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64 3/5
Verifying : 1:openssl-libs-1.0.1e-60.el7.x86_64 4/5
Verifying : 1:openssl-1.0.1e-60.el7.x86_64 5/5
Installed:
nginx.x86_64 1:1.16.0-1.el7.ngx
Dependency Updated:
openssl.x86_64 1:1.0.2k-16.el7_6.1 openssl-libs.x86_64 1:1.0.2k-16.el7_6.1
Complete!
nginx 的安装相对还是简单些的,
启动并开机启动:
[root@centos7 ~]# systemctl start nginx
[root@centos7 ~]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
好了,站点默认的网址就可以看到nginx的默认页了