cat > nginx.sh <<EOF
#停止apache,避免抢占端口号
systemctl stop httpd
#创建nginx运行账户,非登录用户,不创建家目录
useradd -M -s /sbin/nologin nginx
#安装依赖包
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc gcc-c
++ make cmake
#解压nginx源码包
tar xf nginx-1.10.3.tar.gz
#进入到解压后的包
cd nginx-1.10.3
#指定安装目录,和模块
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stu
b_status_module --with-http_ssl_module #指定安装目录,和模块
make && make install
#启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#写入开机启动
echo "/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf" >> /etc/r
c.local
#查看运行端口,确定安装成功
netstat -tanp|grep 80
EOF
需要提前准备nginx源码包在脚本执行目录下!
原文:https://www.cnblogs.com/haojinfei/p/13661738.html