nginx
cat <<EOF
*************************************
* 即 将 进 行 的 操 作 *
* 2. nginx -- nginx 安装 *
*************************************
EOF
cd /root
useradd www -s /sbin/nologin
yum install pcre-devel
/usr/bin/yum list installed wget >/dev/null || /usr/bin/yum -y install wget
cd /root
wget http://nginx.org/download/nginx-1.12.0.tar.gz && echo "download ok." || echo "download fail."
tar zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx-1.12.0 \
--sbin-path=/usr/local/nginx-1.12.0/sbin/nginx \
--conf-path=/usr/local/nginx-1.12.0/conf/nginx.conf \
--error-log-path=/usr/local/nginx-1.12.0/logs/error.log \
--http-log-path=/usr/local/nginx-1.12.0/logs/access.log \
--pid-path=/usr/local/nginx-1.12.0/logs/nginx.pid \
--lock-path=/usr/local/nginx-1.12.0/logs/nginx.lock \
--http-client-body-temp-path=/usr/local/nginx-1.12.0/cache/client_temp \
--http-proxy-temp-path=/usr/local/nginx-1.12.0/cache/proxy_temp \
--http-fastcgi-temp-path=/usr/local/nginx-1.12.0/cache/fastcgi_temp \
--http-uwsgi-temp-path=/usr/local/nginx-1.12.0/cache/uwsgi_temp \
--http-scgi-temp-path=/usr/local/nginx-1.12.0/cache/scgi_temp \
--user=www \
--group=www \
--with-pcre \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_auth_request_module \
--with-file-aio \
--with-stream
echo "预编译ok" >>/root/install_nginx.log
sleep 5
echo "——————————————————————————1、src/core/nginx.h源码修改——————————————————"
#define nginx_version 6.0
#define NGINX_VERSION "6.0"
#define NGINX_VER "Microsoft-IIS/" NGINX_VERSION
#define NGINX_VAR "Microsoft-IIS"
# ——————————>>>>
# vim src/core/nginx.h
#define nginx_version 6.0
#define NGINX_VERSION "6.0"
#define NGINX_VER "Microsoft-IIS/" NGINX_VERSION
#define NGINX_VAR "Microsoft-IIS"
sed -i "s/#define nginx_version 1012000/#define nginx_version 6.0/" src/core/nginx.h
sed -i "s/#define NGINX_VERSION \"1.12.0\"/#define NGINX_VERSION \"6.0\"/" src/core/nginx.h
sed -i "s@#define NGINX_VER \"nginx/\" NGINX_VERSION@#define NGINX_VER \"Microsoft-IIS/\" NGINX_VERSION@" src/core/nginx.h
sed -i "s@#define NGINX_VAR \"NGINX\"@#define NGINX_VAR \"Microsoft-IIS\"@" src/core/nginx.h
echo "——————————————————————————2、src/http/ngx_http_header_filter_module.c源码修改—————"
#static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
# ———————————>>>>>
# vim src/http/ngx_http_header_filter_module.c
#static u_char ngx_http_server_string[] = "Server: Microsoft-IIS" CRLF;
sed -i "s/static u_char ngx_http_server_string\[\] = \"Server: nginx\" CRLF\;/static u_char ngx_http_server_string\[\] = \"Server: Microsoft-IIS\" CRLF\;/" src/http/ngx_http_header_filter_module.c
echo "——————————————————————————3、src/http/ngx_http_special_response.c源码修改—————"
#"<hr><center>" NGINX_VER "</center>" CRLF
#"<hr><center>" NGINX_VER "(buyaogaoshiqingwogennijiang)</center>" CRLF
sed -i "s@\"<hr><center>\" NGINX_VER \"<\/center>\" CRLF@\"<hr><center>\" NGINX_VER \"(buyaogaoshiqingwogennijiang)<\/center>\" CRLF@" src/http/ngx_http_special_response.c
#
#sed -i "s/#define nginx_version 1012000/#define nginx_version 6.0/" src/core/nginx.h
#sed -i "s/#define NGINX_VERSION \"1.12.0\"/#define NGINX_VERSION \"6.0\"/" src/core/nginx.h
#sed -i "s@#define NGINX_VER \"nginx/\" NGINX_VERSION@#define NGINX_VER \"Microsoft-IIS/\" NGINX_VERSION@" src/core/nginx.h
#sed -i "s@#define NGINX_VAR \"NGINX\"@#define NGINX_VAR \"Microsoft-IIS\"@" src/core/nginx.h
#sed -i "s/static u_char ngx_http_server_string\[\] = \"Server: nginx\" CRLF\;/static u_char ngx_http_server_string\[\] = \"Server: Microsoft-IIS\" CRLF\;/" src/http/ngx_http_header_filter_module.c
#sed -i "s@\"<hr><center>\" NGINX_VER \"<\/center>\" CRLF@\"<hr><center>\" NGINX_VER \"(buyaogaoshiqingwogennijiang)<\/center>\" CRLF@" src/http/ngx_http_special_response.c
echo "源码修改ok" >>/root/install_nginx.log
sleep 5
make
v=$?
if [ $v -gt 0 ]; then
echo "1.nginx 编译有错误,清检查";
exit 1
else
echo "1.nginx 编译ok"
echo "nginx 编译ok" >>/root/install_nginx.log
fi
sleep 5
make install
ret=$?
if [ $ret -gt 0 ]; then
echo "2.nginx 编译安装有错误,清检查";
exit 1
else
echo "2.nginx 编译安装ok"
echo "nginx 编译安装ok" >>/root/install_nginx.log
fi
sleep 5
echo "nginx安装成功,请【再次】确认已经上传nginx服务脚本"
# "vim /etc/init.d/nginx"
# "chmod +x /etc/init.d/nginx"
# "chkconfig --add nginx"
# "chkconfig nginx on"
# "service nginx start"
# "thx"
sleep 5
chmod +x /etc/init.d/nginx
ls -l /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
service nginx start && sleep 1 && service nginx status
ps -ef |grep nginx
echo ""
curl -I http://127.0.0.1
cat install_nginx.log
echo "nginx 安装配置OK,请检查服务启动是否正常"