#! /Bin/bash
User = "'whoam '"
If ["$ user "! = "Root"]; then
Echo "execute $0 with Root !!! "
Exit 0;
Fi
Sed-I's/^ exclude/# exclude/'/etc/yum. conf & Yum-y install GCC & sed-I's/^ # exclude/'/etc/yum. conf
# Getting source files
Yum-y install GCC gcc-C ++ Autoconf automake make
Yum-y install zlib-devel OpenSSL -- devel PCRE-devel
CP./nginx.txt/tmp/
CP./CONF/tmp/-R
CD/tmp
If [! -F "nginx-1.2.0.tar.gz"]; then
Echo "downloading http://nginx.org/download/nginx-1.2.0.tar.gz !!! "
Wget http://nginx.org/download/nginx-1.2.0.tar.gz
Fi
Tar-zxvf nginx-1.2.0.tar.gz
If [! -F "ngx_cache_purge-1.3.tar.gz"]; then
Echo "http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz !!! "
Wget http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz
Fi
Tar-zxvf ngx_cache_purge-1.3.tar.gz
If [! -F "pcre-8.10.tar.gz"]; then
Echo "downloading http://webserver.googlecode.com/files/pcre-8.10.tar.gz !!! "
Wget http://webserver.googlecode.com/files/pcre-8.10.tar.gz
Fi
Tar-zxvf pcre-8.10.tar.gz
If [! -F "openssl-1.0.0c.tar.gz"]; then
Echo "downloading http://www.openssl.org/source/openssl-1.0.0c.tar.gz !!! "
Wget http://www.openssl.org/source/openssl-1.0.0c.tar.gz
Fi
Tar-zxvf openssl-1.0.0c.tar.gz
If [! -F "gperftools-2.0.tar.gz"]; then
Echo "https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz !!! "
Wget https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz
Fi
Tar-zxvf gperftools-2.0.tar.gz
CD gperftools-2.0
./Configure -- prefix =/usr
Make & make install
Echo "/usr/local/lib">/etc/lD. So. conf. d/usr_local_lib.conf
/Sbin/ldconfig
Mkdir/tmp/tcmalloc
Chmod 0777/tmp/tcmalloc
Mkdir/usr/local/nginx
CD/usr/local/nginx
Wget https://naxsi.googlecode.com/files/naxsi-0.47.tgz
If [$? -EQ 0]
Then
Tar xvzf naxsi-0.47.tgz
Rm-RF naxsi-0.47.tgz
Else
Echo "downloading https://naxsi.googlecode.com/files/naxsi-0.47.tgz failured !!! "
Exit 1
Fi
Rm-RF naxsi-0.47.tgz
Music naxsi-0.47 naxsi
# Change file before compile
Sed-I's/\ "nginx/\" firefoxbug/I '/tmp/nginx-1.2.0/src/CORE/nginx. h
# Sed-I's/\ "nginx_ver \"/secon/'/tmp/nginx-1.2.0/src/HTTP/ngx_http_special_response.c
Sed's/> nginx </> firefoxbug </'-I/tmp/nginx-1.2.0/src/HTTP/ngx_http_special_response.c
# Complie nginx with new ARGs
Groupadd WWW
Useradd-G www-S/bin/false-M WWW
D/tmp/nginx-1.2.0
. /Configure -- user = WWW -- group = WWW -- prefix =/usr/local/nginx -- With-PCRE = .. /pcre-8.10 -- With-OpenSSL = .. /openssl-1.0.0c -- add-module = .. /ngx_cache_purge-1.3 -- with-http_stub_status_module -- with-http_ssl_module -- with-http_gzip_static_module -- without-mail_pop3_module
-- Without-mail_smtp_module -- without-mail_imap_module -- without-http_uwsgi_module -- without-http_scgi_module -- with-google_perftools_module -- add-module =/usr/local/nginx/naxsi/naxsi_src/
Make & make install
If [$? -Ne 0]; then
Echo "error"
Exit 1
Fi
# Set auto start scripts
CP/tmp/nginx.txt/etc/init. d/nginx
Chmod U + x/etc/init. d/nginx
Chkconfig -- add nginx
Chkconfig -- level 345 nginx on
Chkconfig -- list nginx
Service nginx start
# Set nginx + nassi
Rm-RF/usr/local/nginx/Conf
MV/tmp/CONF/usr/local/nginx/
Mkdir/home/Cache/
Mkdir/home/logs/
Service nginx reload