参考安装脚本
#!/bin/bash
read -p "请输入你要定制的服务名称:" Servername
echo "开始安装依赖包..."
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel gcc gcc-c++ autoconf automake
useradd -s /sbin/nologin -M nginx
if [ -e nginx-1.10.3.tar.gz ]
then
tar -xvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
sed -i "s@\"nginx/\" NGINX_VERSION@\"$Servername\/\" NGINX_VERSION@g" src/core/nginx.h
sed -i "s@\"Server: nginx\" CRLF@\"Server: $Servername\" CRLF@g" src/http/ngx_http_header_filter_module.c
sed -i "s@\<hr\>\<center\>nginx\<\/center\>@\<hr\>\<center\>$Servername\<\/center\>@g" src/http/ngx_http_special_response.c
./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-pcre
make -j 4 && make install
ln -s /optl/nginx/sbin/nginx /usr/sbin/
nginx
echo "Nginx安装完成"
sleep 1
cp /opt/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
mkdir /etc/nginx
sleep 1
ln -s /opt/nginx/conf/* /etc/nginx/
sed -i "/\#tcp_nopush/a\ server_tokens off\;" /opt/nginx/conf/nginx.conf
nginx -s reload
else
echo "请检查nginx安装包是否存在"
fi
centos nginx安装脚本
最新推荐文章于 2023-12-26 19:42:14 发布