一丶环境准备 关闭防火墙,安装软件包,上传nginx压缩包并解压,配置yum源
二丶创建用户nginx
三丶进入解压路径,并安装服务到指定路径
四丶安装服务
五丶编写脚本
PS:脚本内容如下 #!/bin/bash #chkconfig: 2345 97 25 #description nginx-server-scryt nginx=/usr/local/nginx/sbin/nginx case "$1" in start) netstat -anlpt | grep nginx if [ $? -eq 0 ] then echo "nginx service running!" else echo "nginx service not running!" $nginx fi ;; restart) $nginx -s reload if [ $? -eq 0 ] then echo "nginx server is begin restart" else echo "nginx server restart" fi ;; stop) $nginx -s stop if [ $? -eq 0 ] then echo "nginx server is stop" else echo "nginx server stop,try again" fi ;; status) netstat -anlpt | grep nginx if [ $? -eq 0 ] then echo "nginx server is running!" else echo "nginx server is not running,try to restart" fi ;; *) echo "Please enter (start|restart|stop|status)" ;; esac exit 0
六丶给脚本执行权限,并移动到安装的路径当中,执行
七丶访问网页
来源:http://www./content-3-26731.html
|