Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use php includes to streamline the process of making a few web pages. The problem with that, however, is that I can't seem to test them locally. They work fine on the server, but my computer doesn't seem to understand them. I tried installing php and apache but it didn't seem to work. What do I need to do to set up a php testing server locally?

share|improve this question
Since php is server side scripting you need to get your apache server working with php enabled. – Zoke Jan 17 '12 at 20:10
But by installing the packages php5 and apache this should work out of the box as far as I know. – Georg Schölly Jan 17 '12 at 20:13
Use php includes (include 'file';)? Not sure I get that one. If you load localhost in a browser, do you see the generic Apache site? Have you sudo apt-get install php5? – user8290 Jan 17 '12 at 23:50
up vote 6 down vote accepted

Install the package libapache2-mod-php5 (which will also install the package for the webserver: apache2). Files can be put in /var/www.

If you then open http://localhost/index.html in your browser, /var/www/index.html is displayed.

The default settings are pretty secure, PHP errors are logged to /var/log/apache2/error_log and not showed in the browser. To change this on a development machine, edit /etc/php5/apache2/php.ini and change display_errors = Off to display_errors = On.

Some modules are not installed by default. If you do image processing, you likely need the GD library for PHP, package php5-gd. To get a list of all available modules, open a terminal, type sudo apt-get install php5- and hit Tab twice to get a list.

See also: How to avoid using sudo when working in /var/www?

share|improve this answer
How can I change the default path /var/www/index.html? – Vitaly Zdanevich Aug 14 '14 at 14:11
Have a look at the configuration files in /etc/apache2/, specifically the ones in /etc/apache2/sites-enabled/. – Lekensteyn Aug 14 '14 at 15:02
Thanks. Other way is creating a link (I am on Ubuntu): ln -s /my/location/of/project/ – Vitaly Zdanevich Aug 14 '14 at 15:42

Install taskel & the LAMP stack

sudo apt-get install tasksel

sudo tasksel install lamp-server

You should now have an apache server with php and mysql.

share|improve this answer

There an easy way to install them all. I usually use it for wordpress theme development.

There you will be guided on how to install it too.

share|improve this answer
I don't really understand why you would need to use something like XAMPP on Ubuntu, which already includes this software. What are your reasons? – thomasrutter May 25 '12 at 4:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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