全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
楼主: web
打印 上一主题 下一主题

[Windows VPS] 怎么让NGINX 开机自动启动呢?

[复制链接]
11#
 楼主| 发表于 2012-1-29 15:04:05 | 只看该作者
webfan 发表于 2012-1-29 14:57
先确保在/etc/init.d/目录下存在启动脚本,然后执行如下操作。
Debian系:
insserv -d nginx

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/sbin/ntpdate us.pool.ntp.org
/etc/init.d/nginx restart
service nginx start


加了,还是不能自动启动NGINX~
12#
 楼主| 发表于 2012-1-29 15:04:44 | 只看该作者
但是手动启动 使用命令
/etc/init.d/nginx restart
或者 service nginx start 均可启动
13#
发表于 2012-1-29 15:05:34 | 只看该作者
cron?
14#
发表于 2012-1-29 15:07:45 | 只看该作者
web 发表于 2012-1-29 15:04
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.

什么系统?
Debian系的还要确保你没有删除开机rc.local自启动。

首先,确定直接在命令行里可以启动不,rc.local文件只是在开机时原样执行。

另外,不要用service,Debian下没有这个命令,RH系中在你用chkconfig --add添加之前也会因找不到服务而返回错误。
15#
 楼主| 发表于 2012-1-29 15:14:04 | 只看该作者
webfan 发表于 2012-1-29 15:07
什么系统?
Debian系的还要确保你没有删除开机rc.local自启动。

rc.local  有的~~
我是CENTOS系统~~~
16#
发表于 2012-1-29 15:19:51 | 只看该作者
web 发表于 2012-1-29 15:14
rc.local  有的~~
我是CENTOS系统~~~

chkconfig --list | grep nginx 看看nginx是否有为on的数值,通常为2到5。

另外就是检查下你的nginx启动脚本,因为init进程中和你登录系统后执行命令的环境不一样,你可能要设置好环境变量。
17#
 楼主| 发表于 2012-1-29 15:21:48 | 只看该作者
webfan 发表于 2012-1-29 15:19
chkconfig --list | grep nginx 看看nginx是否有为on的数值,通常为2到5。

另外就是检查下你的nginx启动 ...

chkconfig --list | grep nginx
nginx           0ff   1ff   2n    3n    4n    5n    6ff

有的~~~~

手动执行 service nginx restart 是可以的~
18#
发表于 2012-1-29 15:24:22 | 只看该作者
web 发表于 2012-1-29 15:21
chkconfig --list | grep nginx
nginx           0ff   1ff   2n    3n    4n    5n    6f ...

那就是启动脚本的问题了,可能环境变量不对,你的nginx是编译安装的还是yum安装的?
19#
 楼主| 发表于 2012-1-29 15:24:34 | 只看该作者
webfan 发表于 2012-1-29 15:19
chkconfig --list | grep nginx 看看nginx是否有为on的数值,通常为2到5。

另外就是检查下你的nginx启动 ...

忽然发现 我们都是WEB辈的~~哈哈
20#
发表于 2012-1-29 15:25:43 | 只看该作者
web 发表于 2012-1-29 15:24
忽然发现 我们都是WEB辈的~~哈哈

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-15 15:27 , Processed in 0.061973 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表