日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

CentOS 7安装Nginx

發布時間:2025/3/21 Nginx 57 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS 7安装Nginx 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.虛擬機網絡模式改為橋接,ip地址改為靜態
可以在網上查閱

2. 關閉防火墻
停止防火墻服務

systemctl stop firewalld.service

關閉開機自啟

systemctl disable firewalld.service

3.?安裝nginx依賴

這里一定要安裝好,不然下面會報錯,錯誤為nginx c compiler cc is not found.

yum -y install gcc-c++ pcre-devel zlib-devel openssl-devel

4.?安裝wget

yum -y install wget

5.?安裝nginx
下載源碼包

wget http://nginx.org/download/nginx-1.17.2.tar.gz

解壓

tar -zxvf nginx-1.17.2.tar.gz

進入解壓出來的文件夾

cd nginx-1.17.2

預編譯

./configure --with-http_ssl_module --prefix=/usr/local/nginx

安裝

make && make install

6.?修改環境變量
編輯環境變量配置文件

vi /etc/profile

在空白處輸入:

PATH=$PATH:/usr/local/nginx/sbin export PATH

保存文件后刷新

source /etc/profile

7.?修改端口
編輯nginx配置文件

vi /usr/local/nginx/conf/nginx.conf

將listen 80改成如圖所示的listen 8080
8.?使用systemctl控制nginx
創建systemctl服務文件

vi /usr/lib/systemd/system/nginx.service

將以下內容輸入:

[Unit] Description=nginx - high performance web server After=network.target remote-fs.target nss-lookup.target[Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop[Install] WantedBy=multi-user.target

保存,使文件生效:

systemctl daemon-reload

然后就可以使用如下命令進行控制:

啟動nginx服務: systemctl start nginx.service 設置開機自啟動: systemctl enable nginx.service 停止開機自啟動: systemctl disable nginx.service 查看服務當前狀態: systemctl status nginx.service 重新啟動服務: systemctl restart nginx.service

9.啟動nginx,并設為開機自啟

systemctl start nginx.service systemctl enable nginx.service

10. 訪問nginx

在瀏覽器中輸入“當前CentOS的ip:8080”,如192.168.1.1:8080

如果出現下面圖片,就說明安裝成功了。

總結

以上是生活随笔為你收集整理的CentOS 7安装Nginx的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。