以下內容僅適用於 Centos 操作系統
一、將系統的軟件包更新到最新版本
yum -y update
二、安裝 Nginx
yum install nginx
三、啟動 Nginx,並設置開機啟動
systemctl start nginx systemctl enable nginx
四、開啟防火牆的 80 端口和 443 端口
firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --zone=public --permanent --add-service=https firewall-cmd --reload
ps:可以通過以下命令關掉防火牆,不推薦在生產環境關閉防火牆!
systemctl stop firewalld
五、其他
Nginx 主配置文件路徑:
/etc/nginx/nginx.conf
虛擬主機配置文件路徑:
/etc/nginx/conf.d/
默認的 www 目錄:
/usr/share/nginx/html/