centos 一键安装配置nginx脚本
installNginx.ssh
用vi或则vim编辑 installNginx.ssh
#!/bin/bash
# author:kwin
# Email:kwinwong@hotmail.com
src="/usr/local/src/"
cd $src
#找到指定进程,并杀死
#findPortKill 80
findPortKill (){
processe=`lsof -i:${1} -n|awk '{print $2}'|grep '^[1-9]'`
for i in $processe
do
# echo "Kill the $1 process [ $i ]"
kill -9 $i
done
}
#将命令所在目录添加到系统参数PATH中,方便调用
addToPATH(){
bin=${1}
echo $PATH|grep ${bin} >/dev/null
if [ $? -ne 0 ]; then
echo "export PATH=\$PATH:${bin}">>/etc/profile
fi
}
nginxConf(){
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
sed -i '35,79c include ../site/*.conf;' /usr/local/nginx/conf/nginx.conf
mkdir /usr/local/nginx/site
cat>/usr/local/nginx/site/default.conf<<EOF
server {
listen 80;
server_name localhost;
gzip on; #开启gizip
gzip_buffers 32 4K;#压缩在内存中缓冲32块? 每块4K
gzip_comp_level 6 ;#压缩级别 推荐6
gzip_min_length 4000;#开始压缩的最小长度4bit
gzip_types text/css text/xml apploation/x-javascript;