I'm using an Ubuntu 12.04 (Server) VM as a development web server. I keep the served files on the VM host, therefore Apache uses NFS mounted directories for DocumentRoot
To keep things as automated, I have Apache set to start on boot.
- I have no problem with automounting NFS at boot.
- I have no problem with starting Apache at boot.
The problem: mountall
starts after upstart fires up Apache.
After fiddle-farting around with upstart
and initctl
I came up with a hack that works — but is certainly not ideal — nor portable.
/etc/fstab
nfs_server:/ /mnt/nfs_server nfs4 _netdev,noauto 0 0
/etc/init.d/apache2
The following was inserted at the top beneath the INIT INFO section:
if [ ! -s "/var/www/default/index.php" ]; then
echo -n " Mounting NFS and Samba shares...."
mount nfs_server:/
result=$?
if [ 0 -ne $result ]; then
echo " ERROR. mount returned $result";
else
echo " [ OK ]";
fi
fi
...
Otherwise, the script is what was installed originally ( see default file here ).
Notes
- I've tried using
mountall
instead of mounting the NFS share by name.- This results in other error messages (notably,
swapon
didn't mount my swap partition) - (however) upon final startup, everything seems fine.
- This results in other error messages (notably,
- This VM will be zipped up and given to other developers. Some may mount using NFS, some may use Samba.
Best Answer
One way to solve this is to change the order that these things load by modifying the order the init script calls them. There may be other (easier) ways to do this, but the bare metal way would be to -