添加源 sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 安裝Nginx sudo yum install -y nginx 直到出現 Co ...
添加源
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安裝Nginx
sudo yum install -y nginx
直到出現 Complete!
啟動
sudo systemctl start nginx.service
啟動後在瀏覽器上訪問,網頁出現以下內容說明安裝成功。
Nginx常用命令
查看版本:nginx -v
查看nginx安裝目錄:ps -ef | grep nginx
檢查配置文件:nginx -t
啟動:systemctl start nginx.service
停止:systemctl stop nginx.service
重新:systemctl restart nginx.service
設置開機自啟動:systemctl enable nginx.service
停止開機自啟動:systemctl disable nginx.service
查看當前狀態:systemctl status nginx.service
查看所有已啟動的服務:systemctl list-units --type=service