1.添加資源包 添加CentOS 7 Nginx yum資源庫,打開終端,使用如下命令(沒有換行):html
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
下載成功顯示:nginx
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:centos
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.啓動Nginxcode
剛安裝的Nginx不會自行啓動。運行Nginx:htm
sudo systemctl start nginx.service
使用該命令查看nginx 運行狀態 systemctl status nginx.service