CentOS6.5下Nginx1.7.4安装记录
1.環(huán)境準(zhǔn)備
yum?-y?install?gcc?gcc-c++?autoconf?automake?make
yum?-y?install?zlib?zlib-devel?openssl?openssl--devel?pcre?pcre-devel?
不執(zhí)行以上兩項安裝的話,就可能會遇到下面我的安裝過程中遇到的情況:
到此頁面下載自己想要的版本:
http://nginx.org/en/download.html
左側(cè)為Linux版本,右側(cè)為Windows版本
使用以下命令下載文件:wget?http://nginx.org/download/nginx-1.7.4.tar.gz
解壓文件:tar?-zxvf?nginx-1.7.4.tar.gz?
切換目錄:cd?nginx-1.7.4
配置:./configure
提示以下信息:./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?,他作用是讓ngnix支持rewrite功能
使用命令安裝:yum?install?pcre-devel.i686
輸入y,回車
最后提示Complete,說明安裝成功:
再執(zhí)行./configure
還是提示同樣的錯誤;
執(zhí)行命令查找PCRE的安裝位置:file?-name?pcre
得到的是:./auto/lib/pcre
根據(jù)提示在后面添加參數(shù)指定Path
執(zhí)行命令:./configure?--with-pcre=./auto/lib/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?library信息!
執(zhí)行以下命令安裝:yum?-y?install?make?zlib?zlib-devel?gcc-c++?libtool
安裝成功之后,再執(zhí)行命令:./configure?--with-pcre=./auto/lib/pcre
最后的提示信息如下:
應(yīng)該是配置成功了,執(zhí)行以下命令安裝:
make?&&?make?install
提示以下錯誤:
該裝的都裝了,還是無法安裝,最后執(zhí)行以下命令解決問題:
yum?-y?install?zlib?zlib-devel?openssl?openssl--devel?pcre?pcre-devel
執(zhí)行之后再執(zhí)行:./configure
再執(zhí)行:make?&&?make?install
安裝完成!
記住上圖中的一些目錄位置!
修改配置文件:
切換目錄:cd?/usr/local/nginx/conf
修改文件:vi?nginx.conf
主要是修改server配置節(jié)的內(nèi)容,按字母i進(jìn)入編輯模式
按ESC鍵,退出編輯模式,按冒號鍵“:”進(jìn)入命令模式,輸入“wq”然后回車,保存并退出;
?
切換到sbin目錄:cd?/usr/local/nginx/sbin
啟動Nginx:./nginx
開放防火墻端口:
/sbin/iptables?-I?INPUT?-p?tcp?--dport?88?-j?ACCEPT
/etc/init.d/iptables?save
?
打開瀏覽器,輸入以下地址訪問吧:
http://你的服務(wù)器IP:88/
看到以下信息了嗎?
我是看到了,看不到的朋友繼續(xù)努力吧!
注意:我在虛擬機(jī)中安裝的時候遇到了類似以下錯誤:
./configure auto/unix: No such file or directory
當(dāng)我使用“mkdir auto/unix”之后,還是提示類似的錯誤,但目錄名又變了。
糾結(jié)了好久,后來發(fā)現(xiàn)是解壓的時候就有好多文件沒有解壓出來,判斷應(yīng)該是安裝包壓縮文件壞了,
所以解壓的時候就少了好多的文件或目錄,重新下載一個解壓安裝問題就解決了。
配置Nginx開機(jī)啟動,vi?/etc/rc.d/rc.local
在文件末尾添加“/usr/local/nginx/sbin/nginx”
Nginx常用命令:
重新加載配置文件:/usr/local/nginx/sbin/nginx -s reload
停止Nginx服務(wù):/usr/local/nginx/sbin/nginx -s stop
其它Nginx命令:
[plain]?view plaincopy
/usr/local/nginx/sbin/nginx?-h??
nginx?version:?nginx/1.7.5??
Usage:?nginx?[-?hvVtq]?[-s?signal]?[-c?filename]?[-p?prefix]?[-g?directives]??
??
Options:??
??-?,-h?????????:?this?help??
??-v????????????:?show?version?and?exit??
??-V????????????:?show?version?and?configure?options?then?exit??
??-t????????????:?test?configuration?and?exit??
??-q????????????:?suppress?non-error?messages?during?configuration?testing??
??-s?signal?????:?send?signal?to?a?master?process:?stop,?quit,?reopen,?reload??
??-p?prefix?????:?set?prefix?path?(default:?/usr/local/nginx/)??
??-c?filename???:?set?configuration?file?(default:?conf/nginx.conf)??
??-g?directives?:?set?global?directives?out?of?configuration?file??
文件權(quán)限問題:
有可能因為目錄、文件權(quán)限過高,導(dǎo)致Nginx無權(quán)訪問文件,可以通過以下命令修改權(quán)限:
chmod -R 777 ./uploadfile
轉(zhuǎn)載于:https://blog.51cto.com/ghostxyj/1702209
總結(jié)
以上是生活随笔為你收集整理的CentOS6.5下Nginx1.7.4安装记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android新浪微博client(七)
- 下一篇: repr