1.添加资源包 添加CentOS 7 Nginx yum资源库,打开终端,使用以下命令(没有换行):
sudo rpm -Uvh 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.mIO8oa: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nginx-release-centos-7-0.el7.ngx ################################# [100%]
2.安装Nginx 在你的CentOS 7 服务器中使用yum命令从Nginx源服务器中获取来安装Nginx:
sudo yum install -y nginx
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_3.1.x86_64 4/5
Cleanup : 1:openssl-libs-1.0.1e-60.el7_3.1.x86_64 5/5
Verifying : 1:nginx-1.12.2-1.el7_4.ngx.x86_64 1/5
Verifying : 1:openssl-libs-1.0.2k-8.el7.x86_64 2/5
Verifying : 1:openssl-1.0.2k-8.el7.x86_64 3/5
Verifying : 1:openssl-1.0.1e-60.el7_3.1.x86_64 4/5
Verifying : 1:openssl-libs-1.0.1e-60.el7_3.1.x86_64 5/5
Installed:
nginx.x86_64 1:1.12.2-1.el7_4.ngx
Dependency Updated:
openssl.x86_64 1:1.0.2k-8.el7 openssl-libs.x86_64 1:1.0.2k-8.el7
Complete!
Nginx将完成安装在你的CentOS 7 服务器中。
3.启动Nginx
刚安装的Nginx不会自行启动。运行Nginx:
sudo systemctl start nginx.service