使用SSL,PCRE,GeoIP,Zlib,Gzip和DAV支持在CentOS 5.5上安装Nginx
Nginx(发音为“引擎x”)是一个免费的,开放源码的高性能HTTP服务器。 Nginx以其稳定性,丰富的功能集,简单的配置和低资源消耗而闻名。 本教程将介绍如何在具有SSL,PCRE,GeoIP,Zlib,Gzip和DAV支持的CentOS 5.5服务器上编译和安装Nginx。
我不会保证这将为您工作!
预安装
首先我们安装httpd-devel,pcre,pcre-devel,zlib,zlib-devel,perl,geoip和geoip-devel这样的包:
yum install -y httpd-devel pcre perl pcre-devel zlib zlib-devel GeoIP GeoIP-devel
下载所需的软件包
cd
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz
wget http://zlib.net/zlib-1.2.5.tar.gz
wget ftp://ftp.openssl.org/source/openssl-0.9.8o.tar.gz
现在你必须解压缩这些文件。
tar -xvf zlib-1.2.5.tar.gz
tar -xvf pcre-8.10.tar.gz
tar -xvf openssl-0.9.8o.tar.gz
下载Nginx源码包
您需要从http://nginx.org/下载Nginx源码包。
cd
wget http://nginx.org/download/nginx-0.7.67.tar.gz
tar -xvf nginx-0.7.67.tar.gz
cd nginx-0.7.67
编译安装Nginx
现在,您可以使用以下命令编译和安装Nginx:
./configure --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-cc-opt='-m32 -march=i386' --with-openssl=/root/openssl-0.9.8o --with-pcre --with-pcre=/root/pcre-8.10 --with-zlib=/root/zlib-1.2.5 --with-http_geoip_module
您可以使用以下命令找到更多选项:
./configure --help
现在运行:
make
make install
配置摘要
nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp"
启动Nginx服务器
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
测试
/usr/local/nginx/sbin/nginx -V