BACK

Configuring Apache with PHP Support

  1. 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
    
  2. Setup Apache with the configure script.
       #cd apache_1.3.20
       #./configure --prefix=/usr/local/httpd --enable-module=so
    
  3. 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
    
  4. Make the PHP binaries and install them.
       #make; make install
    
    1. 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
      
    2. Then run make and make install for PHP again.
         #make; make install
      
  5. 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
    
  6. Stop the daemon and make and make install the Apache binary.
       #/etc/rc.d/apache stop
       #make; make install
    
  7. 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
    
  8. 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
    
  9. Copy the apachectl script that starts the daemon to the run control directory.
      #cp /usr/local/httpd/bin/apachectl /etc/rc.d
    
  10. 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.
    1. Make new symbolic links to the script.
         #cd /etc/rc.d/rc3.d
         #ln -s ../apachectl S12ApachePHP
         #ln -s ../apachectl K12ApachePHP
      
    2. Backup the old script and rename the apachectl script to the original script's name.
         #cd ..
         #mv apache apache.old
         #mc apachectl apache
      
  11. Start the daemon using the /etc/rc.d/apache script.
       #/etc/rc.d/apache start
    
  12. Test Apache.
    1. Open a Konqueror or Web browser window and enter http://localhost in the title bar or the FQDN if DNS is setup.
    2. You will see the default Apache index.html page.
    3. This page is located in /usr/local/httpd/htdocs/index.html.
    4. Edit or replace index.html for your purposes.
  13. Testing PHP.
    1. 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>
      
    2. Save the file as test.php in the same directory as index.html.
    3. Edit the index.html page to include a hyperlink to the test.php page.
      
         <a href="test.php">PHP Test</a>
      
      
    4. 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