redhat6.4安装nginx
Nginx是一個高性能的HTTP和反向代理服務器.
Nginx 使用 Unix 下常用的 ./configure && make && make install過程來編譯安裝.
configure 腳本確定系統所具有一些特性,特別是 nginx 用來處理連接的方法。然后,它創建 Makefile 文件。
官網:http://nginx.org/
下載頁面:http://nginx.org/download/nginx-1.11.3.tar.gz
1、nginx的準備工作
下載nginx-1.11.3.tar.gz包到你指定的目錄下后,解壓:
解壓后在當前目錄下會生成一個nginx-1.11.3的目錄
進入解壓后的目錄,運行configure命令,
./configure --prefix=/home/aplus/nginx這時會報出一個如下錯誤:
./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= option.這是因為沒有PCRE library的原因所致,通過下面的命令安裝相關的lib即可解決
2、PCRE庫的安裝:
官網:http://www.pcre.org/
下載頁面:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
選擇最新版本下載:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
1)解壓:
tar –zxvf pcre-8.10.tar.gz解壓目錄為:pcre-8.10
然后進入到 cd pcre-8.10,進行配置、編譯、安裝
2)配置
./configure --prefix=/usr/local/pcre3)編譯pcre
makeubuntu中在進行編譯時可能遇到如下錯誤(redhat6.4中沒有遇到以下錯誤):
make pcre時會出錯
解決方法:
安裝build-essential
4)安裝pcre
make install3、nginx的安裝
1)配置
./configure –prefix=/home/aplus/nginx –with-pcre=/usr/local/pcre/
注意:此處而不是安裝的路徑,應該是pcre源文件的路徑
正確的命令是:
2)編譯
make3)安裝
make installNginx會被安裝在/home/aplus/nginx目錄下(也可以使用參數–prefix=指定自己需要的位置)
安裝成功后 /home/aplus/nginx 目錄下有四個子目錄分別是:conf、html、logs、sbin 。
其中 Nginx 的配置文件存放于 conf/nginx.conf,
bin文件是位于 sbin 目錄下的 nginx 文件。
確保系統的 80 端口沒被其他程序占用,運行 sbin/nginx 命令來啟動 Nginx,
打開瀏覽器訪問此機器的 IP,如果瀏覽器出現 Welcome to nginx! 則表示 Nginx 已經安裝并運行成功
4、注意:
一、nginx的常用命令:
cd到/home/aplus/nginx/sbin下,
啟動:./nginx -p /home/aplus/nginx
關閉:./nginx -s stop -p /home/aplus/nginx
重啟:./nginx -s reload -p /home/aplus/nginx
二、nginx啟動常見錯誤:
[aplus@redhat6 sbin]$ ./nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)解決方法:
原因是/home/aplus/nginx/conf/nginx.conf中配置的nginx的監聽端口是<=1024的,小于1024的必須使用root用戶啟動nginx
總結
以上是生活随笔為你收集整理的redhat6.4安装nginx的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Apache Karaf配置远程调试
- 下一篇: tar time stamp in th