CentOS6.4系統下Nginx安裝記錄,centos6.4nginx

來源:互聯網
上載者:User

CentOS6.4系統下Nginx安裝記錄,centos6.4nginx

1.環境準備

yum-yinstallgccgcc-c++autoconfautomakemake

yum-yinstallzlibzlib-developensslopenssl--develpcrepcre-devel

不執行以上兩項安裝的話,就可能會遇到下面我的安裝過程中遇到的情況:

到此頁面下載自己想要的版本:

https://nginx.org/en/download.html

左側為Linux版本,右側為Windows版本

使用以下命令下載檔案:wgethttps://nginx.org/download/nginx-1.7.4.tar.gz

解壓檔案:tar-zxvfnginx-1.7.4.tar.gz

切換目錄:cdnginx-1.7.4

配置:./configure

提示以下資訊:./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.

Youcaneitherdisablethemodulebyusing--without-http_rewrite_module

option,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrary

staticallyfromthesourcewithnginxbyusing--with-pcre=option.

需要安裝pcre,他作用是讓ngnix支援rewrite功能

使用命令安裝:yuminstallpcre-devel.i686

輸入y,斷行符號

最後提示Complete,說明安裝成功:

再執行./configure

還是提示同樣的錯誤;

執行命令尋找PCRE的安裝位置:file-namepcre

得到的是:./auto/lib/pcre

根據提示在後面添加參數指定Path

執行命令:./configure--with-pcre=./auto/lib/pcre

提示如下資訊:

./configure:error:theHTTPgzipmodulerequiresthezliblibrary.

Youcaneitherdisablethemodulebyusing--without-http_gzip_module

option,orinstallthezliblibraryintothesystem,orbuildthezliblibrary

staticallyfromthesourcewithnginxbyusing--with-zlib=option.

還缺少zliblibrary資訊!

執行以下命令安裝:yum-yinstallmakezlibzlib-develgcc-c++libtool

安裝成功之後,再執行命令:./configure--with-pcre=./auto/lib/pcre

最後的提示資訊如下:

應該是配置成功了,執行以下命令安裝:

make&&makeinstall

提示以下錯誤:

該裝的都裝了,還是無法安裝,最後執行以下命令解決問題:

yum-yinstallzlibzlib-developensslopenssl--develpcrepcre-devel

執行之後再執行:./configure

再執行:make&&makeinstall

安裝完成!

記住中的一些目錄位置!

修改設定檔:

切換目錄:cd/usr/local/nginx/conf

修改檔案:vinginx.conf

主要是修改server配置節的內容,按字母i進入編輯模式

按ESC鍵,退出編輯模式,按冒號鍵“:”進入命令模式,輸入“wq”然後斷行符號,儲存並退出;

切換到sbin目錄:cd/usr/local/nginx/sbin

啟動Nginx:./nginx

開放防火牆連接埠:

/sbin/iptables-IINPUT-ptcp--dport88-jACCEPT

/etc/init.d/iptablessave

開啟瀏覽器,輸入以下地址訪問吧:

https://你的伺服器IP:88/

看到以下資訊了嗎?

我是看到了,看不到的朋友繼續努力吧!

注意:我在虛擬機器中安裝的時候遇到了類似以下錯誤:

./configure auto/unix: No such file or directory

當我使用“mkdir auto/unix”之後,還是提示類似的錯誤,但目錄名又變了。

糾結了好久,後來發現是解壓的時候就有好多檔案沒有解壓出來,判斷應該是安裝包壓縮檔壞了,

所以解壓的時候就少了好多的檔案或目錄,重新下載一個解壓安裝問題就解決了。

配置Nginx開機啟動,vi/etc/rc.d/rc.local

在檔案末尾添加“/usr/local/nginx/sbin/nginx”

Nginx常用命令:

重新載入設定檔:/usr/local/nginx/sbin/nginx -s reload

停止Nginx服務:/usr/local/nginx/sbin/nginx -s stop

其它Nginx命令:

[plain]view plaincopy

/usr/local/nginx/sbin/nginx-h

nginxversion:nginx/1.7.5

Usage:nginx[-hvVtq][-ssignal][-cfilename][-pprefix][-gdirectives]

Options:

-,-h:thishelp

-v:showversionandexit

-V:showversionandconfigureoptionsthenexit

-t:testconfigurationandexit

-q:suppressnon-errormessagesduringconfigurationtesting

-ssignal:sendsignaltoamasterprocess:stop,quit,reopen,reload

-pprefix:setprefixpath(default:/usr/local/nginx/)

-cfilename:setconfigurationfile(default:conf/nginx.conf)

-gdirectives:setglobaldirectivesoutofconfigurationfile

檔案許可權問題:

有可能因為目錄、檔案許可權過高,導致Nginx無權訪問檔案,可以通過以下命令修改許可權:

chmod -R 777 ./uploadfile

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.