Running Php in Apache on Linux

| Comments

I haven’t done php for a while, but at work our prototypes are in html/php. So, I needed to get Apache webserver downloaded and working on my Linux box with php. Here’s how it all went down.

I haven’t done php for a while, but at work our prototypes are in html/php. So, I needed to get Apache webserver downloaded and working on my Linux box with php. Here’s how it all went down:

Install apache2 and the php handler:

1
sudo apt-get install apache2 libapache2-mod-php5

Find the DocumentRoot:

1
sudo emacs /etc/apache2/sites-available/default

Mine defaulted to /var/www/. I have a limited number of my projects on this box right now, so I decided to setup sym links to the project directories:

1
cd /var/www/;  ln -s ~/dev/records-proto/ proto

Now I need to tell apache that I want my .html files treated as php files too (because that’s how our designer did it). I did a grep on ‘AddType’:

1
cd /etc/apache2/; grep AddType * -r

That turned up the file that you need to edit:

1
sudo emacs mods-enabled/php.conf &

I made the php handler line look like this (added the .html on the end):

1
AddType application/x-httpd-php .php .phtml .php3 .html

Now the server’s going to need a restart:

1
sudo /etc/init.d/apache2 restart

Now, I point my favorite web browser to this address (using the sym-link), and I’m good to go:

1
firefox http://localhost/proto &

Comments