作者在 2014-07-13 01:40:32 发布以下内容
这篇博客里说的很明白 http://razius.com/articles/launching-services-after-vagrant-mount/
原因是启动nginx的时候本地目录还没映射到虚拟机,nginx当然启动不了,解决办法就是在目录映射完以后再次启动nginx。
vi /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/local/nginx/sbin/nginx
env PID=/usr/local/nginx/logs/nginx.pid
expect fork
respawn
respawn limit 10 5
pre-start script
$DAEMON -t
if [ $? -ne 0 ]
then exit $?
fi
end script
exec $DAEMON