The problem
You want to add a new domain and you find that the serve command fails to restart nginx.
dos2unix: converting file /vagrant/scripts/serve.sh to Unix format ...
* Restarting nginx
...fail!
php5-fpm stop/waiting
php5-fpm start/running, process 2798
What happened?
Back in February 2015, a commit was made to the Homestead repository which would allow setting of the listen port when creating serving a new domain, rather than defaulting to port 80. A little while ago, Taylor fixed the aliases stub file.
This is perfect for a brand new Homestead VM or update the VM, or (maybe?) if you run homestead provision
again.
What if you have a homestead kicking around already? Glad you asked!
The solution
It's a simple fix, really. If you have a look in the /home/vagrant/.bash_aliases
file, you'll find the serve()
function. All you need to do is find the following line:
sudo bash /vagrant/scripts/serve.sh "$1" "$2"
And add the default port - 80 - to the end of it:
sudo bash /vagrant/scripts/serve.sh "$1" "$2" 80
If you're feeling adventurous, and you want the ability to specify the port, you can update the serve function to accept a third parameter and reference it as follows:
function serve() {
if [[ "$1" && "$2" && "$3" ]]
then
sudo dos2unix /vagrant/scripts/serve.sh
sudo bash /vagrant/scripts/serve.sh "$1" "$2" "$3"
else
echo "Error: missing required parameters."
echo "Usage: "
echo " serve domain path port"
fi
}
Update: As Ortwin van Vessem points out in the comments, don't forget to update the ~/.homestead/aliases
file on your host machine, which will preserve the changes if you provision a new environment.