Nerdrium Home

Macintosh

Linux

Web Design

Case Mods

Gardening

Photography

Recipes

 

My Blog

 

Facebook

Twitter

Installing PHP

by Michael Greifenkamp (February 20th, 2004)

Now that MySQL is installed, the final piece of this glorious webserving triad that I desire is PHP. I downloaded PHP 4.3.4 (tar.gz) from php.net.

And once again, I downloaded the gzipped file to my user directory on the server, and logged in as the superuser (root).

# su -l
(Enter your password to log in as root.)

# mv /home/username/php-4.3.4.tar.gz /home/installers/
# cd /home/installers/
# gzip -d php-4.3.4.tar.gz
# tar xvf php-4.3.4.tar
# mv php-4.3.4 /usr/local
# cd /usr/local/php-4.3.4
# ./configure --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs
# make
# make install

Now in the ./configure line up above, I only listed two of the extra parts that can be added during the configuration, which are modules for MySQL and Apache apxs. My actual configure line has all sorts of other stuff in it, and yours may as well, but I'm not going to get into everything that can or should be added during configuration.

After the installation is complete, we once again have to modify our friend the httpd.conf file. Shut down Apache first. Note also that PHP already backed up your last httpd.conf and then added some stuff to the file. You'll add a few more things on your own.

# cd /usr/local/apache2
# bin/apachectl stop
# cd /usr/local/apache2/conf
# vi httpd.conf

Under the AddType lines that we added for Server Side Includes put the following:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

(Save the file and quit.)

Now we need to create a simple file to make sure that PHP is installed and is working. Create a file called "info.php" using your favorite editor (I use vi).

# cd /web
# vi info.php

The file should simply have this single line in it:
<?php phpinfo(); ?>
(Save the file and quit.)

Now start Apache back up, and MySQL if it isn't already running.

# cd /usr/local/apache2
# bin/apachectl start
# cd /usr/local/mysql
# bin/mysqld_safe &

Open a browser window, point to that server, and the file info.php. You should see a whole lot of stuff about PHP and the installed modules, as well as a chunk about what version of MySQL is running.

Comments? Questions? Did I do something drastically inappropriately? Drop me a line...

--Michael