Apache Installation Tips for PHP, SQL Server and MySQL Logo Monday, October 23, 2017
By The Voodooman what's new | faq | about

!!! WARNING !!!

This Guide is Deprecated!

Please go to the New Guide here.

Installation Instructions

These are the installation instructions that you have to follow to install Apache/PHP with database support. Depending on what features you decide to have (such as types of database support), you can skip certain sections.

Important: It is necessary to follow the installation instructions in sequence otherwise some of the features may not work correctly. It is assumed that you know how to change directories, unzip files and use an editor under a *nix environment at this stage. It is also assumed that you've downloaded all the files to /usr/local/src.

Some of the commands that are issued in the instructions below may be unfamiliar to you. If you are not really sure what the output of certain commands look like, then click on these images below for reference. Your screen should look like something similar when you issue the respective commands.

  • Sample output while running a tar command.
  • Sample output while running a ./configure command.
  • Sample output while running a make command.
  • Sample output while running a make install command


    1. Uncompress Files

    It is assumed that you've already changed directories to /usr/local/src. If you've not done so, then type:

    cd /usr/local/src
    Proceed to uncompress all the downloaded files as follows:
  • tar -zxvf apache_*.tar.gz
  • tar -zxvf php-*.tar.gz
  • tar -zxvf ZendOptimizer*.tar.gz
  • tar -zxvf mhash-*.tar.gz
    (Note: Do this only if you're using the mhash module for PHP)
  • tar -zxvf mysql-*.tar.gz
    (Note: Do this only if you're using the MySQL database engine)
  • tar -zxvf freetds-*.tgz
    (Note: Do this only if you're using the SQL Server database engine)
  • tar -zxvf DBD-Sybase-*.tar.gz
    (Note: Do this only if you're using the SQL Server database engine AND you want perl support for SQL server. It's generally a good idea to do this, if you're using SQL server.)
  • tar -zxvf DBI-*.tar.gz
    (Note: Do this only if you want perl support for any database engine. It's generally a good idea to do this always.)
  • tar -zxvf Msql-Mysql-modules-*.tar.gz
    (Note: Do this only if you're using the MySQL database engine AND you want perl support for MySQL. It's generally a good idea to do this, if you're using MySQL.)
  • TOP

    2. Compile MHASH Module

    Note that you need to do this step ONLY if you want to enable MHASH support for the PHP module. If you do not use any of PHP's mhash_xx functions, then you probably don't want this module. If you have already installed Apache completely and find that you need this module at a later time, then follow this step and then from step 8 to the end.
  • cd /usr/local/src/mhash-*
  • ./configure
  • make
  • make install
  • TOP

    3. Compile MySQL

    Note that you need to do this step ONLY if you are using MySQL as your database engine and it is not already installed for you. If you've already installed Apache completely and find that you need this module at a later time, then follow this step, step 5 and then step 8 to the end.
  • cd /usr/local/src/mysql-*
  • ./configure --prefix=/usr/local/mysql (Note that if you have low memory in your system, then add the parameter: --with-low-mem to the configure command)
  • make
  • make install
  • Note: Purists may note that the prefix specified is /usr/local/mysql instead of /usr/local. You can use /usr/local if you like, but I like to keep package specific binaries and libraries in their own specific directories (it's a personal preference).

    TOP

    4. Compile DBI

    This is the Database Independent driver for Perl. It is a good idea to install this anyway, because it does not affect the running of Apache.
  • cd /usr/local/src/DBI-*
  • perl Makefile.PL
  • make
  • make install
  • TOP

    5. Compile Msql-Mysql-modules

    Note that you need to do this step ONLY if you are using MySQL as your database engine and it is not already installed for you. If you are going to do this step, you should have already completed step 3 first.
  • cd /usr/local/src/Msql-Mysql-modules-*
  • perl Makefile.PL
    Select MySQL install only and hit enter for the rest of the questions (the defaults should work OK)
  • make
  • make install
  • TOP

    6. Compile FreeTDS

    Note that you need to do this step ONLY if you are using SQL Server as your database engine. Here's where things get a little different between Linux and FreeBSD. Follow the necessary steps according to your OS.

    FreeBSD users ONLY

    Some FreeBSD systems do not have GNU make installed by default. If this is the case, you'll need to download and install gmake and gettext for FreeTDS to compile correctly. The steps to do this are as follows:

  • cd /usr/local/src
  • tar -zxvf gettext*.tar.gz
  • tar -zxvf make*.tar.gz
  • cd /usr/local/src/gettext*
  • ./configure
  • make
  • make install
  • cd /usr/local/src/make*
  • ./configure
  • make
  • make install
  • mv /usr/local/bin/make /usr/local/bin/gmake
  • Log out and then log back in
  • The last step (logging out and back) is necessary, since tcsh will not see gmake on your path otherwise and you'll need to specify the path name explicitly to invoke it.

    For both Linux and FreeBSD
  • cd /usr/local/src/freetds*
  • ./configure --with-tdsver=7.0 --prefix=/usr/local/freetds --enable-dbmfix
  • gmake
  • gmake install
  • Purists may note that the prefix specified is /usr/local/freetds instead of /usr/local. You can use /usr/local if you like, but I like to keep package specific libraries in their own specific directories (it's a personal preference).

    FreeBSD users ONLY

  • ldconfig -m /usr/local/freetds/lib
  • Edit the file /etc/defaults/rc.conf and search for the variable ldconfig_paths. Copy this line into the file /etc/rc.conf, if it does not already exist there. Then add /usr/local/freetds/lib to the list of paths contained by the variable ldconfig_paths in /etc/rc.conf. Note that if you used --prefix=/usr/local above, then there's no need to perform this step.
  • Linux users ONLY
  • Edit the file /etc/ld.so.conf and add /usr/local/freetds/lib to the end of the list.
  • ldconfig
  • For Both Linux and FreeBSD
    If you're using sh, bash or ksh for your shell, then type:
  • SYBASE=/usr/local/freetds
  • LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib
  • export SYBASE LD_LIBRARY_PATH
  • If you're using csh, then type:
  • setenv SYBASE /usr/local/freetds
  • setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$SYBASE/lib
  • TOP

    7. Compile DBD-Sybase

    This is the Sybase Driver for Perl. It is a good idea to install this anyway, if you are using SQL Server, because it does not affect the running of Apache.
  • cd /usr/local/src/DBD-*
  • perl Makefile.PL
    You may see some warning messages here. Most can be ignored.
  • make
  • make install
  • TOP

    8. Compile Apache/PHP

    Here we are.... almost at the end of our journey!
  • cd /usr/local/src/apache*
  • Open your favourite text editor and type the following into it (Enable the modules that you need accordingly):
    ./configure \
    --prefix=/usr/local/apache \
    --disable-module=imap \
    --disable-module=actions \
    --disable-module=alias \
    --disable-module=asis \
    --disable-module=auth \
    --disable-module=cgi \
    --disable-module=env \
    --disable-module=include \
    --disable-module=setenvif \
    --disable-module=status \
    --disable-module=userdir \
    --activate-module=src/modules/php4/libphp4.a
    Save this file and call it apache_conf. Now exit your editor. Note: Purists may note that the prefix specified is /usr/local/apache instead of /usr/local. You can use /usr/local if you like, but I like to keep package specific libraries and binaries in their own specific directories (it's a personal preference).
  • chmod 755 apache_conf
  • ./apache_conf
    This will take a little while to complete the command.
  • cd ../php-*
  • Again, fire up your favourite editor and type the following into it (enabling/disabling the modules you need and adjusting the path names according to your setup):
    ./configure \
    --with-mysql \
    --with-mhash \
    --with-sybase=/usr/local/freetds \
    --with-apache=../apache_1.3.23 \
    --without-gd \
    --without-java \
    --enable-versioning \
    --disable-xml \
    --disable-debug \
    --enable-debug=no \
    --disable-session \
    --enable-sigchild
    Save this file as php_conf and exit your text editor again.
  • chmod 755 php_conf
  • If you're using SQL Server: Open the file ext/sybase/php_sybase_db.c with your favourite text editor and replace all occurrences of 'dbopen' with 'tdsdbopen' (there should be 3 instances). Save this file and exit. Note: As of PHP version 4.0.6, it is no longer necessary to carry out this step.
  • ./php_conf
  • make
  • make install
  • cd ../apache*
  • ./apache_conf
  • make
  • make install
  • TOP

    9. Installing the Zend Optimizer

    This is an optional step that is recommended, because the Zend Optimizer makes the PHP code run so much smoother when it is installed. To install the optimizer, do the following:
  • cd /usr/local/src/ZendOptimizer*
  • cd data
  • cp ZendOptimizer.so /usr/local/apache/libexec
  • If you installed apache above with --prefix=/usr/local instead of --prefix=/usr/local/apache, then you would be copying to /usr/local/libexec of course.
    Next, create a file called php.ini in the directory /usr/local/lib using your favourite text editor. Add the following lines into it (adjusting your paths as necessary):
    zend_optimizer.optimization_level = 15
    zend_extension = "/usr/local/apache/libexec/ZendOptimizer.so" 
    zend_loader.enable = Off
    
    ; Compress output for .gz compliant browsers
    output_handler = ob_gzhandler           
    
    ; allow ASP-style <% %> tags
    asp_tags = Off
    
    ; number of significant digits displayed in floating point numbers
    precision = 14
    
    ; Whether to be year 2000 compliant 
    ;(will cause problems with non y2k compliant browsers)
    y2k_compliance = Off                    
    
    ; Implicit flush tells PHP to tell the output layer to flush itself
    implicit_flush = Off
    
    ; Decides whether PHP may expose the fact that it is installed on 
    ; in the HTTP header reply
    expose_php = Off
    
    ; Maximum execution time of each script, in seconds	
    max_execution_time = 30                 
    
    ; Maximum amount of memory a script may consume (8MB)
    ;memory_limit = 8M                      
    	
    sybase.interface_file = "/usr/local/freetds/interfaces"
    	
    ;error_reporting        =       E_ALL
    ;display_errors =       On
          
    You may wish to adjust some of the parameters such as max_execution_time, precision etc. to your own requirements. Notice that some of the options (memory_limit, error_reporting, display_errors) are commented out. These options may be enabled for debugging and removed when you move the code into production. Feel free to experiment with the settings for your own optimal needs.

    TOP

    Reinstalling Features

    Let's say you've installed apache completely and you wish to add or subtract something (let's say you want to enable the MHASH module and enable Image Mapping on Apache). It's pretty simple -- all you have to do is to repeat the steps from the module downwards (in this case Step 2). Don't forget that if something has already been compiled, then do a make clean before you type make at every stage. In this case, you'll need to do a make clean while recompiling apache in step 8.

    TOP


  • <<Previous: Downloads ^Up to Mayukh's World^ Next: Configuration >>

    Apache Installation Walkthrough
    Last updated 12/25/2001