linux 源碼安裝nginxhtml
http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.htmllinux
安裝說明
nginx
系統環境:CentOS 6.4
c++
軟件:nginx-1.9.12.tar.gz
數據庫
安裝方式:源碼編譯安裝
api
安裝位置:/opt/nginx
dom
下載地址:http://nginx.org/en/download.htmlide
1.yum 安裝一些依賴包網站
yum install pcre* zlib* gcc openssl openssl-devel libxml* libxslt* gd-devel GeoI GeoIP-data GeoIP-devel perl-devel perl-ExtUtils-Embed gcc-c++ui
2.建立目錄 建立用戶
[root@niaoyun-101 tools]# mkdir -p /opt/nginx
[root@niaoyun-101 tools]# mkdir -p /opt/tools
[root@niaoyun-101 tools]# groupadd www
[root@niaoyun-101 tools]# useradd -g www www
3.編譯
[root@niaoyun-101 tools]#wget http://nginx.org/download/nginx-1.9.12.tar.gz
[root@niaoyun-101 tools]#tar zxf nginx-1.9.12.tar.gz
[root@niaoyun-101 tools]#cd nginx-1.9.12
[root@niaoyun-101 nginx-1.9.12]# ./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-select_module --with-poll_module --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_p_w_picpath_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_perl_module --with-threads
錯誤信息:
./configure: error: the GeoIP module requires the GeoIP library.
You can either do not enable the module or install the library.
解決辦法:
安裝 MaxMind 的 GeoIP 庫
MaxMind 提供了免費的 IP 地域數據庫(GeoIP.dat),不過這個數據庫文件是二進制的,須要用 GeoIP 庫來讀取,因此除了要下載 GeoIP.dat 文件外(見下一步),還須要安裝能讀取這個文件的庫。
# wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz # tar -zxvf GeoIP.tar.gz # cd GeoIP-1.4.6 # ./configure # make; make install
剛纔安裝的庫自動安裝到 /usr/local/lib 下,因此這個目錄須要加到動態連接配置裏面以便運行相關程序的時候能自動綁定到這個 GeoIP 庫:
# echo '/usr/local/lib' > /etc/ld.so.conf.d/geoip.conf
# ldconfig
(http://www.vpsee.com/2011/03/install-nginx-with-geoip-module-for-country-targeting/)解決問題網站
[root@niaoyun-101 nginx-1.9.12]# make
[root@niaoyun-101 nginx-1.9.12]# make install
4.配置文件:/opt/nginx/conf/nginx.conf
網站目錄:/opt/nginx/html
5.啓動
[root@niaoyun-101 nginx-1.9.12]# /opt/nginx/sbin/nginx
[root@niaoyun-101 tools]# ps -ef | grep nginx