#!/bin/bash
nginxTargz="/home/nginx/software/nginx/nginx-1.12.1.tar.gz"
checkExist(){
if [ -e "/usr/local/nginx" ];then
echo "Nginx已安装..."
exit
fi
}
checkExist
# 查询是否有
if [ -e $nginxTargz ];
then
cd /home/nginx/software/nginx
if [ -e "/home/nginx/software/nginx/pcre-8.38" ];then
echo "存在该文件夹,删除..."
rm -rf /home/nginx/software/nginx/pcre-8.38
fi
echo "1.安装pcre..."
tar -xvf pcre-8.38.tar
cd pcre-8.38
./configure
make
make install
echo "2.安装zlib..."
cd /home/nginx/software/nginx
if [ -e "/home/nginx/software/nginx/zlib-1.2.11" ];then
echo "存在该文件夹,删除..."
rm -rf /home/nginx/software/nginx/zlib-1.2.11
fi
tar -xvf zlib-1.2.11.tar
cd zlib-1.2.11
./configure
make
make install
echo "3.安装openssl-1.0.2n..."
cd /home/nginx/software/nginx
if [ -e "/home/nginx/software/nginx/openssl-1.0.2n" ];then
echo "存在该文件夹,删除..."
rm -rf /home/nginx/software/nginx/openssl-1.0.2n
fi
tar -xvf openssl-1.0.2n.tar
cd openssl-1.0.2n
./config
make
make install
echo "4.FastDFS的nginx模块安装..."
cd /home/nginx/software/fastdfs
if [ -e "/home/nginx/software/fastdfs/fastdfs-nginx-module-master" ];then
echo "存在该文件夹,删除..."
rm -rf /home/nginx/software/fastdfs/fastdfs-nginx-module-master
fi
unzip fastdfs-nginx-module-master.zip
cd fastdfs-nginx-module-master/src
sed -i 's#ngx_module_incs="/usr/local/include"#ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"#' /home/nginx/software/fastdfs/fastdfs-nginx-module-master/src/config
sed -i 's#CORE_INCS="$CORE_INCS /usr/local/include"#CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"#' /home/nginx/software/fastdfs/fastdfs-nginx-module-master/src/config
echo "5.nginx安装..."
cd /home/nginx/software/nginx
if [ -e "/home/nginx/software/nginx/nginx-1.12.1" ];then
echo "存在该文件夹,删除..."
rm -fr /home/nginx/software/nginx/nginx-1.12.1
fi
tar -zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure --prefix=/usr/local/nginx --add-module=/home/nginx/software/fastdfs/fastdfs-nginx-module-master/src
sed -i 's# -Wno-unused-parameter -Werror -g# -Wno-unused-parameter -g#' /home/nginx/software/nginx/nginx-1.12.1/objs/Makefile
make
make install
if [ -e "/usr/local/nginx/conf/" ];then
echo "存在该文件夹,不创建"
else
mkdir -p /usr/local/nginx/conf/
fi
cp /home/nginx/conf/nginx.conf /usr/local/nginx/conf/
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
fi
ubuntu18.04自动安装nginx脚本
最新推荐文章于 2024-10-14 16:42:33 发布