How to configure apache for php on Linux

Hi there,

I am new to php and trying to install php on linux. I just install apache and php on my ubuntu and i know i need to modify apache config but don't know how.

could you please tell me how to do it.
Who is Participating?
check "Edit the Apache Configuration File (httpd.conf)" section at below link :
koala-londonAuthor Commented:
Use what your Linux distribution offers. Following instructions from php's or apache's web site is a mistake. They'll probably tell you how to get the last release, compile, install and so on.
When using a packaged linux distribution, it's already done for you.
Furthermore, when a security patch is released, you get it almost automatically. When a new release is made (from Ubuntu), you get it too. Your system is up-to-date and the most secure. Installing PHP or apache manually, then let it live (ie, never upgrade it) is a major security risk, provided your web server is public.

Anyway, the most simple way with Ubuntu is:
sudo aptitude install apache2 php5 libapache2-mod-php5

Open in new window

If apache is already installed, no problem.
The last one is the one that installs and configures PHP for apache.
After that, it should work out-of-the-box

Create in your "DocumentRoot" (probably /var/www or /srv/www if you didn't change your apache configuration) a file called test.php, containing:

Open in new window

And try to call http://your.server/test.php
If everytjhing works, you'll have a beautiful web page describing your apache/php configuration, modules loaded and so on...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.