Recently I had to install a PHP server on my Ubuntu machine to test some code. So, I opened up my terminal and typed:
sudo apt-get install php5
To my surprise, this automatically installed apache2 and libapache2-mod-php5. Looks great guys! I write my first php file, save it, and load it in my browser.
… and nothing works! It had me save the file without executing any PHP code. Ok, what’s wrong? I tried to a2enmod php5, but it tells me that “Module php5 already enabled”
Hmm… well let’s’ try restarting apache2. Oh, it looks like PHP is working now. Looking at my apt-get logs, it looks like php5 was set up after the apache2 server was started, so apt-get install php5 didn’t quite work out of the box.
tip: after installing php5 on ubuntu, restart apache!
(this may seem obvious, but since apt automatically started the apache server, I had mistakenly assumed that everything was already good to go. my bad!)