nginx 作为系统服务
来源:互联网 发布:怎么查看淘宝等级手机 编辑:程序博客网 时间:2024/05/16 13:04
开机自启动nginx
这里使用的是编写shell脚本的方式来处理
vi /etc/init.d/nginx
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
#nginx程序路径
nginxd=/usr/local/nginx/sbin/nginx
#nginx配置文件路径
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx pid文件的路径,可以在nginx的配置文件中找到
nginx_pid=/var/run/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
fi
}
# Stop nginx daemons functions.
stop() {
}
# reload nginx service functions.
reload() {
}
# See how we were called.
case "$1" in
start)
stop)
reload)
restart)
status)
*)
esac
exit $RETVAL
:wq
设置文件的访问权限
chmod a+x /etc/init.d/nginx
这样在控制台就很容易的操作nginx了:查看Nginx当前状态、启动Nginx、停止Nginx、重启Nginx
同样的修改了nginx的配置文件nginx.conf,也可以使用上面的命令重新加载新的配置文件并运行,可以将此命令加入到rc.local文件中,这样开机的时候nginx就默认启动了
vi /etc/rc.local
加入一行
将nginx添加为系统服务
chkconfig --add nginx
chkconfig nginx on
# chkconfig: - 85 15 必须写
- nginx 作为系统服务
- 添加nginx作为系统服务
- 添加Nginx作为系统服务
- windows系统下将nginx作为系统服务启动
- Windows下Nginx作为服务启动
- 【服务器】Nginx 作为应用服务器映射服务
- nginx添加为系统服务
- nginx设置为系统服务
- 添加nginx为系统服务
- 将Tomcat6作为系统服务安装
- 把tomcat作为系统服务,随机启动
- Subversion作为windows系统服务自启动
- linux中将mongo作为系统服务启动
- linux中将mongo作为系统服务启动
- 将mongod 作为系统服务启动
- Win10 mongodb 作为系统服务启动
- Linux中将mongo作为系统服务启动
- redis在linux系统作为服务启动
- SAN和NAS
- 《COM技术内幕》整理的一个FAQ
- OpenGL中的数据——Buffer
- Swift学习资源
- WebView显示网页
- nginx 作为系统服务
- HDU 2027 统计元音 (吃回车的方法)
- C++作业2
- 利用代码来添加图片按钮
- 数据存储
- 如何从零开始学习Ruby
- ProgressDialog的详细使用总结
- 三维图像技术与OpenGL基础理论
- 变量、数据类型和运算符