For those
of you who know anything about web-design, then chances are
you will probably know or heard about the php hypertext pre-processor.
Basically its the fastest server side language there is today,
and the best thing is its totally free.
This
little how-to will explain to you how would go about installing
the php 4.0 sp1 onto your apache 1.3.x server. This is useful
if you want to run php to mysql database Websites or if you
just want to play around with php in your spare time.
"A
popular choice is to build the Apache module version. In order
to build PHP as a dynamic module for Apache-1.3.x you have
to first have Apache installed. Assuming Apache is already
installed, make sure the shared object module is enabled.
To check this, type: httpd
-l You should see something like: Compiled-in modules:
http_core.c mod_so.c
You will most likely have a lot more modules than what is
shown here. As long as mod_so.c shows up in the list, PHP
should be happy."
The first things
as always is to download the latest release from php.net,
in this case the file used was php-4.0.4pl1.tar.gz.
Once you have downloaded it to the appropriate directory you will
need to uncompress it and this is done by the following command
tar -xzvf php-4.0.4pl1.tar.gz,
(which by now should be very familiar to you).
Now that
the files have been extracted you need to get into the new
directory by typing cd
php-4.0.4pl1 at the command prompt. The next thing
to do is configure the script with the options that you require.
In this case we compiled it for apache with the support of
mySQL, if your serious about using php's advantages then you
will probably want mySQL (if so see the next section below).
Also note that this is considered a "dynamic" installation,
if you wish to have a "static" installation then
please read the supplied INSTALL
file very carefully.
To configure
the script for mySQL you need to type ./configure
--with-mysql --with-apxs. If you get an error telling
you that the apxs script could not be found, look for it on
your system and if you find it (you should use the locate
command, e.g. locate
apxs), provide the full path to it as: --with-apxs=/path/to/apxs.
Once you have done this then all that is required is to do
a make, and
then make install
(be sure to be logged in as 'root' for make
install command to work).
Now you
need to activate the Apache module for php so that your web
server knows what to do when given a php file (this requires
you to have the source files for apache lying around still,
if you don't then just re-download the same version as you
have installed and then uncompressing it)). To automatically
build Apache with PHP support, use:
cd apache_1.3.x
./configure
--prefix=/dir/to/apache --activate-module=src/modules/php4/libphp4.a
make
make install
The next
and final step is to check and make sure that its all working
correctly, The make
install command in the previous step should have done
most of your work for you. It actually edits your httpd.conf
file and tries to enable the dynamic PHP module. To verify
this, look for a line that looks like this: LoadModule
php4_module libexec/libphp4.so The actual path before
the libphp4.so part might differ slightly. This is likely
fine. And finally you need to tell Apache which file extension
should trigger PHP. You do this by creating a special mime
type and associating it with an extension. We suggest using:
AddType application/x-httpd-php
.php (this is probably already in the httpd.conf
file witha # infront of it, just remove the # to enable it).
Finally
you need to copy php.ini-dist
to the appropriate place (normally /usr/local/lib/php.ini)
and edit if necessary. Once you have made these changes you
should be ready to restart your server and try it out. Type:
apachectl restart.
If all
has gone well then your ready to test your newly installed
php. To test it you need to create a test file named test.php
in your web tree somewhere and put some test PHP tags in it.
<?phpinfo () ?>
is a good first test. This tag tells PHP to do a braindump
and tells you all sorts of things about itself. The html file
should look someting like this:
<html><head><title>PHP
4.0</title></head>
<body
bgcolor="#FFFFFF"><center>
<?phpinfo
() ?>
</center></body>
</html>
If your
install worked then the above should give a large colourful
page full of statistics and informartion about php4 and the
settings it has on your machine etc., if you don't see anything
at all (i.e. just a white page) then you should follow the
steps again carefully and read the INSTALL
file provided. The install isn't the easiest, but once you
have done it you will be able to do it again without a problem.
|