添加nginx到系统服务注意事项
来源:互联网 发布:java版本积分商城 编辑:程序博客网 时间:2024/05/11 16:00
1、在/etc/init.d/目录下编写脚本,名为nginx
#!/bin/bash# nginx Startup script for the Nginx HTTP Server
# this script create it by ruijie. at 2014.02.26
# if you find any errors on this scripts,please contact ruijie.
# and send mail to ruijie at gmail dot com.
# ruijie.qiao@gmail.com
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog!"
$nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog!"
$nginxd -s stop
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/nginx
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog!"
#kill -HUP `cat ${nginx_pid}`
$nginxd -s reload
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|help}"
exit 1
esac
exit $RETVAL
[root@example ~]# chmod 755 /etc/init.d/nginx
[root@example ~]# chkconfig --add nginx
3、nginx启动、停止、无间断服务重启
[root@example ~]# service nginx start
[root@example ~]# service nginx stop
[root@example ~]# service nginx reload
添加完以后使用上述命令如果提示No such file or directory 那么可能是因为文件格式不是unix,需要使用命令转化文件格式如下:
两个命令的用法相同,不同的是两个命令使用的环境不一样.
dos2unix在CentOS系列的系统中使用,fromdos则在Ubuntu系列的系统中使用。
用法:dos2unix filename = fromdos filename
意思是:转换文件格式,将windos系统的文件转换成linux系统可以使用的文件格式,否则文件在linux系统中可能会出现错误,如:文件中显示^m 这样的错误字符。
导致这样的错误出现的原因是,windos环境中的换行符是\r\n,而linux系统中的换行符直接\n就行了。
CENTOS下yum install dos2unix -y
UBUNTU下apt-get install tofrodos ?
0 0
- 添加nginx到系统服务注意事项
- 搬瓦工nginx添加到系统服务
- Windows下添加MySQL服务到系统服务以及注意事项
- 添加nginx到windows服务
- nginx添加为系统服务
- 添加nginx作为系统服务
- 添加Nginx作为系统服务
- 添加nginx为系统服务
- 将Nginx添加到系统服务(使其可使用service命令控制)
- 将nginx添加为系统服务
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加zip版Tomcat到系统服务
- 添加zip版Tomcat到系统服务
- 添加自启动服务到系统
- 添加Mysql到Windows系统服务
- Tomcat JBOSS 中间件 添加到系统服务
- Android之MVC模式的使用
- APMserv5.2.6的session_start错误解决办法
- PHP RSA加解密示例
- sgu148 B-station(Bomb)
- 转义字符的使用
- 添加nginx到系统服务注意事项
- maven pom.xml详解(三)
- Android AutoCompleteTextView自动完成文本框
- [洛谷1271] 聚会的快乐
- 影子页表
- C++11新特性
- 用java语言进行RSA加解密
- iOS图片压缩方法
- Orcal常用函数