Installing PHP5 and Apache on Ubuntu
If you are doing any kind of PHP development, you'll almost always be using Apache along with it. Here's the quick and easy way to get PHP up and running on your Ubuntu box.
First, you'll want to add the extra repositories to Ubuntu's sources.list file.
From a command shell, you will run the following commands:
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
Note that if apache is already installed you can omit the first line. Your web files will now be found in /var/www/
The Geek is the founder of How-To Geek and a geek enthusiast. When he's not coming up with great how-to articles, he's probably writing at his personal blog. This article was written on 09/11/06 and tagged with: Ubuntu, Adding Software, SysAdmin, PHP


you don't have to do the 3rd line there, it will automatically install that if you have apache2 package installed.
Thanks so much for this article!!! It works perfectly!
Worked perfectly on my machine. Although I didn't add anything to me sources.list file because I working mostly with Feisty, and yes, the third line didn't do anything as warren mentioned.
I tried it, and it doesnt parse php files.
Instead of that it offers me to download it as a .php file which is not parsed.
kubiak2;
In that case you have to enable the libapache2-mod-php5.
just run:
user@host:/# sudo a2enmod php5
user@host:/# /etc/init.d/apache2 force-reload
And the php files are parsed.
I had this all working fine then Ubuntu Update Manager did it's thing, now I can't parse php files. I have re-run all of the suggestions from above with no luck. The symptoms are as described by kubiak2 above. Anyone have a similar love of automatic updates !!
I had the problem with Firefox asking to save/open the .php file. BlackF1re's suggestion for a force-reload did the trick for me (although I had to run that with sudo).
Installing php and cgi support for apache2 in Ubuntu
you need to have universe source list in your sources.list file
sudo apt-get install libapache2-mod-php4 php4-cli php4-common php4-cgi
Next we edit /etc/apache2/apache2.conf file and check the index files are correct
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
If you want to enable some Apache modules (SSL, rewrite, suexec, and include)
sudo a2enmod ssl
sudo a2enmod rewrite
sudo a2enmod suexec
sudo a2enmod include
Restart Apache to make sure all is well.
sudo /etc/init.d/apache2 restart
After I installed php5 and restarted my ubuntu machine, the php.test file I made didnt work. It just made it like a file download in firefox. So I did apache2 restart and now it works!
sudo /etc/init.d/apache2 restart
just so you know, if you run plesk, that will totally remove it.
Thats worked wayyy to easy, but i still need help configuring nola pro, give me a call warren or benj!