CentOS安裝Nginx


一、Nginx安裝

1.添加Nginx到yum源

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.安裝nginx

yum install -y nginx

3.啟動nginx

systemctl start nginx.service

4.設置開機啟動

systemctl enable nginx.service

5. 停止開機自啟動

systemctl disable nginx.service

6.查看服務當前狀態

systemctl status nginx.service

7.重啟Nginx服務

systemctl restart nginx.service

8.查看所有已啟動的服務

systemctl list-units --type=service

二、防火牆配置

1.防火牆打開80端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

參數說明:

--zone #作用域

--add-port=80/tcp  #添加端口,格式為:端口/通訊協議

--permanent   #永久生效,沒有此參數重啟后失效

2.重啟防火牆生效

firewall-cmd --reload

三、常用目錄

網站文件存放默認目錄  /usr/share/nginx/html

網站默認站點配置  /etc/nginx/conf.d/default.conf

自定義Nginx站點配置文件存放目錄  /etc/nginx/conf.d/

Nginx全局配置  /etc/nginx/nginx.conf

四、Nginx配置

1.配置端口轉發80轉到8092,配置后重啟Nginx

vi /etc/nginx/conf.d/default.conf


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM