Yesterday I was getting back to a client’s project that I’d worked on over a month ago. Because of this time gap, I couldn’t use a previous virtual machine I’d made to work on it. So I decided I would create a new one using Vagrant, since Vagrant is buzzword cool right now.
I created a vagrant file that created a new Linux server and installed php. Then to test it, I did this:
Created a index.html file with this in it.
PHP where are you? <?php echo phpinfo();
But the phpinfo block didn’t show up.
I then proceeded to spend four hours messing with the Vagrant file, the shell script that installs php/mysql/apache, the configuration of apache on the VM, and many other things. In the process I learned about how apache loads modules including php, which was different than how it happens on OSX. I learned about three ways to configure your virtual machine with Vagrant – shell script, Chef, and Puppet. I learned about installing mysql non-interactively.
Finally I gave up and decided I’d come back to it tomorrow and left the office. When I got downstairs and was walking to my car I realized why it wasn’t working.
Did you techies catch it?
It was my test file’s name. index.html. It should have been index.php. You can configure apache to handle php in a .html file, but it’s generally a bad idea and not the default configuration.
Sure enough I walked in this morning, renamed the file and it worked like a champ.
Now I need to look over the changes to the Vagrantfile and bootstrap.sh – I decided to us the shell script approach – to make sure my attempts at fixing didn’t do anything bad to my VM install.