步骤一、首先确认托管商是否在系统中安装gcc,输入命令gcc -v ,显示如下跳过步骤二
[root@MyCloudServer /]# gcc -v
Using built-in specs.
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
步骤二、安装gcc和gcc-c++
yum -y install gcc
yum -y install gcc-c++
步骤三、安装pcre-devel(在Nginx编译需要 PCRE(Perl Compatible Regular Expression),因为Nginx 的Rewrite模块和HTTP 核心模块会使用到PCRE正则表达式语法)
yum -y install pcre-devel
步骤四、安装openssl和openssl-devel
yum -y install openssl
yum -y install openssl-devel
步骤五、下载nginx
wget http://nginx.org/download/nginx-1.3.11.tar.gz /opt/
步骤六、安装nginx
# tar -zxvf nginx-1.3.11.tar.gz
# cd nginx-1.3.11
# ./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module
# make
# make install
其他编译参数说明
--prefix=/usr
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--pid-path=/var/run/nginx/nginx.pid
--lock-path=/var/lock/nginx.lock
--user=www-nginx
--group=www
--with-http_flv_module
--with-http_gzip_static_module
--http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/
--http-proxy-temp-path=/var/tmp/nginx/proxy/
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
--with-http_stub_status_module #nginx状态
--with-http_ssl_module #支持HTTPS
--with-http_sub_module #支持URL重定向
--with-pcre=/usr/include/pcre/ (启用正规表达式)
--with-md5=/usr/lib #md5是一种加密算法
--with-http_memcached_module (启用memcache缓存)
--with-http_rewrite_module (启用支持url重写)
--with-ipv6 (支持ipv6)
步骤七、为nginx指定编译后的配置文件
sbin/nginx -c /opt/nginx/conf/nginx.conf
sbin/nginx -s reload