作者:沉沦 | 来源:互联网 | 2023-09-11 14:48
#!binbashurl“http:127.0.0.1nginx_status”culrusrbincurl#检测nginx进程是否存在functionping{sbinpidof
#!/bin/bash
url=“http://127.0.0.1/nginx_status”
culr=/usr/bin/curl
#检测nginx进程是否存在
function ping {
/sbin/pidof nginx | wc -l
}
#检测nginx性能
function active {
$curl $url 2>/dev/null | grep ‘Active’ | awk ‘{print $ NF}’
}
function reading {
$curl $url 2>/dev/null | grep ‘Reading’ | awk ‘{print $ $2}’
}
function writing {
$curl $url 2>/dev/null | grep ‘Writing’ | awk ‘{print $ $4}’
}
function waiting {
$curl $url 2>/dev/null | grep ‘Waiting’ | awk ‘{print $ $6}’
}
function accepts {
$curl $url 2>/dev/null | awk NR= =33 | awk ‘{print $ $1}’
}
function handled {
$curl $url 2>/dev/null | grep NR==3 | awk ‘{print $ $2}’
}
$!
shell脚本部署Nginx
#!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH#安装依赖环境yum install -y patch openssl make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils#安装PCREwget http://downloads.sourceforge.net/project/pcre/pcre/8.36/pcre-8.36.tar.gztar zxf pcre-8.36.tar.gzcd pcre-8.36/./configure && make && make installcd …/#安装NGINXwget http://nginx.org/download/nginx-1.6.3.tar.gztar zxf nginx-1.6.3.tar.gzcd nginx-1.6.3/./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-http_spdy_modulemake && make installcd …/ln -s /usr/local/lib/libpcre.so.1 /libln -s /usr/local/nginx/sbin/nginx /usr/bin/nginxrm -f /usr/local/nginx/conf/nginx.confmkdir -p /home/wwwroot/defaultchmod +w /home/wwwroot/defaultmkdir -p /home/wwwlogschmod 777 /home/wwwlogschown -R nobody:nobody /home/wwwroot/defaultwget -c http://soft.vpser.net/lnmp/ext/init.d.nginxcp init.d.nginx /etc/init.d/nginxchmod +x /etc/init.d/nginxchkconfig --level 345 nginx on/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT/sbin/iptables-saveldconfigwget -c http://blog.zbusa.com/upload/nginx.confmv nginx.conf /usr/local/nginx/conf//etc/init.d/nginx start
作者:王哲理
链接:https://www.jianshu.com/p/097acc266cc8
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。