国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

CentOS7安裝Nginx并配置自動啟動的方法步驟

2024-08-30 12:29:58
字體:
來源:轉載
供稿:網友

1、官網下載安裝包

http://nginx.org/en/download.html,選擇適合Linux的版本,這里選擇最新的版本,下載到本地后上傳到服務器或者centos下直接wget命令下載。

CentOS7,安裝,Nginx,自動啟動

切換到/usr/local目錄,下載軟件包

# cd /usr/local# wget http://nginx.org/download/nginx-1.11.5.tar.gz

2、安裝nginx

先執行以下命令,安裝nginx依賴庫,如果缺少依賴庫,可能會安裝失敗,具體可以參考文章后面的錯誤提示信息。

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

解壓安裝包

# tar -zxvf nginx-1.11.5.tar.gz

nginx被解壓到了/usr/local/nginx-1.11.5 目錄下(不要把壓縮包解壓到/usr/local/nginx目錄下,或者將解壓后的目錄重命名為nginx,因為nginx會默認安裝到/usr/local/nginx目錄下),切換到nginx-1.11.5/目錄

# cd /usr/local/nginx-1.11.5/

執行# ./configure

# ./configure

該操作會檢測當前系統環境,以確保能成功安裝nginx,執行該操作后可能會出現以下幾種提示:

    checking for OS

     + Linux 3.10.0-123.el7.x86_64 x86_64

    checking for C compiler ... not found

    ./configure: error: C compiler cc is not found

    如果出現以上錯誤提示信息,執行yum install gcc-c++安裝gcc,

    ./configure: error: the HTTP rewrite module requires the PCRE library.

    You can either disable the module by using --without-http_rewrite_module

    option, or install the PCRE library into the system, or build the PCRE library

    statically from the source with nginx by using --with-pcre=<path> option.

    如果出現上面提示,表示缺少PCRE庫

    ./configure: error: the HTTP gzip module requires the zlib library.

    You can either disable the module by using --without-http_gzip_module

    option, or install the zlib library into the system, or build the zlib library

    statically from the source with nginx by using --with-zlib=<path> option.

    如果出現以上提示,表示缺少zlib庫

 如果沒有出現./configure: error提示,表示當前環境可以安裝nginx,執行make和make install編譯nginx

# make# make install

沒有出錯的話,表示nginx已經成功安裝完成,默認安裝位置為/usr/local/nginx,之前的/usr/local/nginx-1.11.5/可以刪除掉了。

如果出現cp: 'conf/koi-win' and '/usr/local/nginx/conf/koi-win' are the same file,可能是你把安裝包解壓到了/usr/local/nginx目錄,解決辦法是將該目錄重命名為其他名稱后再執行make,make install.

3、配置nginx開機啟動

切換到/lib/systemd/system/目錄,創建nginx.service文件vim nginx.service

# cd /lib/systemd/system/# vim nginx.service

文件內容如下:

[Unit]Description=nginx After=network.target  [Service] Type=forking ExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx reloadExecStop=/usr/local/nginx/sbin/nginx quitPrivateTmp=true  [Install] WantedBy=multi-user.target

退出并保存文件,執行systemctl enable nginx.service使nginx開機啟動

# systemctl enable nginx.service

systemctl start nginx.service    啟動nginx

systemctl stop nginx.service    結束nginx

systemctl restart nginx.service    重啟nginx

4、驗證是否安裝成功

輸入http://服務器IP/ 如果能看到nginx的界面,就表示安裝成功了

CentOS7,安裝,Nginx,自動啟動

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到服務器教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 会昌县| 长白| 理塘县| 金乡县| 皮山县| 邵阳市| 娄底市| 朝阳市| 裕民县| 祁连县| 汾西县| 凌海市| 施甸县| 正定县| 阳信县| 锡林郭勒盟| 曲阳县| 顺义区| 大竹县| 凤阳县| 当雄县| 沅陵县| 双城市| 独山县| 唐山市| 江西省| 通海县| 扎兰屯市| 修文县| 达孜县| 成都市| 盐池县| 外汇| 河津市| 阿克苏市| 洪雅县| 故城县| 黄石市| 寿阳县| 濉溪县| 南华县|