1.創建檔案夾用來存放nginx
我的放在 /usr/apps/nginx

2.下載
進入到自己創建的檔案夾nginx下執行
wget http://nginx.org/download/nginx-1.13.0.tar.gz
如果提示未找到wget命令
先執行
yum -y install wget

3.解壓
在nginx檔案夾下解壓

4.編譯

進入nginx/nginx-1.13.0檔案夾下
[root@localhost nginx]# ls
nginx-1.13.0 nginx-1.13.0.tar.gz
[root@localhost nginx]# cd nginx-1.13.0
[root@localhost nginx-1.13.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE Makefile man objs README src
然后開始編譯

./configure
報錯1:
錯誤原因:
缺少編譯環境,安裝編譯原始碼所需要的工具和庫
解決錯誤./configure: error: C compiler cc is not found錯誤
當前檔案夾下執行命令
yum install gcc gcc-c++ ncurses-devel perl
===========================================================
解決報錯1后執行./configure可能會遇到報錯2
報錯2
./configure: error: the HTTP rewrite module requires the PCRElibrary.錯誤:
錯誤原因
缺少HTTP rewrite module模塊,禁用或者安裝所需要的模塊,我們選擇安裝模塊:
執行命令
yum install pcre pcre-devel

解決報錯2后執行./configure可能會遇到報錯3
報錯3
./configure: error: the HTTP gzip module requires the zliblibrary.錯誤
錯誤原因
缺少HTTP zlib類別庫,我們選擇安裝模塊
執行命令
yum install zlib gzip zlib-devel

5.解決錯誤后重新編譯


6安裝nginx
make & make install
安裝成功

7.啟動nginx
首先進入我們安裝的nginx檔案夾下
[root@localhost nginx-1.13.0]# cd /usr/local/nginx
[root@localhost nginx]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
[root@localhost nginx]# cd sbin
[root@localhost sbin]# ls
nginx

啟動
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# ./nginx
查看nginx行程是否在運行
ps -ef|grep nginx

以上代表運行成功
瀏覽器訪問
ip addr


轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/138616.html
標籤:其他
