nginx 从vagant挂载目录中加载nginx.conf配置进行开机启动

nginx从vagrant挂载目录中读取配置启动,将nginx加入开机启动项!开机启动的时候nginx会因为加载不了配置导致启动失败!

原因是开机启动nginx服务在vagrant挂载之前,导致无法正常映射!

解决方法:

 vim /etc/init/vagrant.conf

 加入以下代码:

# nginx
description "nginx http daemon"
author "Silviu Tantos " # Listen and start after the vagrant-mounted event
start on vagrant-mounted
stop on runlevel [!2345] env DAEMON=/usr/sbin/nginx
env PID=/var/run/nginx.pid expect fork
respawn
respawn limit 10 5 pre-start script
$DAEMON -t
if [ $? -ne 0 ]
then exit $?
fi
end script exec $DAEMON 注:红色部分改为自己的环境 参考:http://razius.com/articles/launching-services-after-vagrant-mount/
上一篇:nullcon HackIM2016 -- Programming Question 3


下一篇:open() 文件读写简要记录