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