BACK
Configuring Apache with PHP Support
- Decompress and untar both sources in the same directory.
#tar -zxvf php-4.0.6.tar.gz
#tar -zxvf apache_1.3.20.tar.gz
- Setup Apache with the configure script.
#cd apache_1.3.20
#./configure --prefix=/usr/local/httpd --enable-module=so
- Setup PHP environment variables with the configure script.
#cd ../php-4.0.6
#./configure --with-apache=../apache_1.3.20 --enable-track-vars \
--with-mysql=/usr/local/mysql
- Make the PHP binaries and install them.
#make; make install
- If, during make, you get errors such as:
microtime.c: In function `php_if_getrusage':
microtime.c:94: storage size of `usg' isn't known
microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function)
microtime.c:97: (Each undeclared identifier is reported only once
microtime.c:97: for each function it appears in.)
microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function)
make[3]: *** [microtime.lo] Error 1
make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/master/php-4.0.1/ext'
make: *** [all-recursive] Error 1
It means you system is broken, you need to relink (symbolicly) /usr/include/linux to point to the include files in your kernel source.
#cd /usr/include
#ln -s /root/kernel/linux/include/linux linux
- Then run make and make install for PHP again.
#make; make install
- Change to the Apache directory and setup Apache with the configure script again, this time we'll enable the PHP module.
#cd ../apache_1.3.20
#./configure --prefix=/usr/local/httpd --enable-module=so \
--activate-module=src/modules/php4/libphp4.a
- Stop the daemon and make and make install the Apache binary.
#/etc/rc.d/apache stop
#make; make install
- Copy the php.ini-dist file to /usr/local/lib/php.ini.
#cd ../php-4.0.6
#cp php.ini-dist /usr/local/lib/php.ini
- Backup the original and edit the httpd.conf file to associate .php files with the PHP processor.
#cd /usr/local/httpd/conf
#cp httpd.conf httpd.conf.original
#vi httpd.conf
Uncomment by removing the # symbol at line 765 in the default httpd.conf so it reads:
AddType application/x-httpd-php .php
- Copy the apachectl script that starts the daemon to the run control directory.
#cp /usr/local/httpd/bin/apachectl /etc/rc.d
- Create the symbolic links in the correct run level to start Apache in, or use the existing links and replace the original script if Apache was previously installed.
- Make new symbolic links to the script.
#cd /etc/rc.d/rc3.d
#ln -s ../apachectl S12ApachePHP
#ln -s ../apachectl K12ApachePHP
- Backup the old script and rename the apachectl script to the original script's name.
#cd ..
#mv apache apache.old
#mc apachectl apache
- Start the daemon using the /etc/rc.d/apache script.
#/etc/rc.d/apache start
- Test Apache.
- Open a Konqueror or Web browser window and enter http://localhost in the title bar or the FQDN if DNS is setup.
- You will see the default Apache index.html page.
- This page is located in /usr/local/httpd/htdocs/index.html.
- Edit or replace index.html for your purposes.
- Testing PHP.
- Open a new file in a text editor and add the following lines:
<html>
<head>
<title>PHP Info Page</title>
</head>
<body>
<?php phpinfo() ?>
</body>
</html>
- Save the file as test.php in the same directory as index.html.
- Edit the index.html page to include a hyperlink to the test.php page.
<a href="test.php">PHP Test</a>
- Save your changes to index.html and reload the browser and test the test.php link. If PHP is working correctly, you will get a page displaying all the environment variables and host settings.
BACK |
|