1

Ubuntu 16.04 running on a vagrant virtual machine on a Windows 8.1 host.

My xdebug.ini file is symlinked to a directory that's shared with the host machine. (This is so I can create new machines and have xdebug.ini set up how I want, and and edits I make to it are always available on the Windows host - I don't have to worry about backing up configurations from the VM)

It seems like the directory is mounted after apache has been started during boot. So I always have to restart apache to load xdebug.

Can I make it so that apache starts after the shared directory is mounted? Or automatically restart apache after startup, so I don't have to do it manually?

1

Ok, so I figured out an answer. I'm not super familiar with manipulating the linux boot sequence and even though this is a vagrant machine, I didn't want to break it.

So I found a vagrant solution for my problem.

I just added this bash script, startup.sh, to the virtual machine in a directory shared with the host:

#!/usr/bin/env bash

service apache2 restart

Then I modified my Vagrantfile to add the following line:

config.vm.provision :shell, path: "startup.sh", run: "always"

So, now my VM restarts Apache after boot, and everything works as I wanted it to.

| improve this answer | |
  • 1
    I was going to make that exact recommendation based on reading your question. Good solution! I would have recommended an inline script rather than a separate file, since it is a one-liner: config.vm.provision :shell, inline: 'apache2ctl restart', run: 'always' – Karl Wilbur Jul 22 '19 at 18:27
  • @KarlWilbur good point about ‘inline’. Thanks! – Buttle Butkus Jul 22 '19 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.