Make your own free website on Tripod.com
BACK

Apache with mod_ssl, PHP, and mod_perl

This page covers configuring Apache 1.3.24 to use mod_perl-1.26, PHP-4.1.2, mod_ssl-2.8.8, and OpenSSL-0.9.6c.  The version of Linux that I am using is SuSE 7.2.  When compiling from sources, you should always get the latest version available especially if the newest version fixed bugs and security holes.  Security is an ongoing process and the sites for each of these software packages should be checked regularly for security updates.



You will need at least these packages:
Apache 1.3.24
mod_ssl 2.8.8
OpenSSL 0.9.6c
mod_perl 1.26
MM 1.1.3
Gzip 1.2.4
Perl 5.6.0
Optional Packages
PHP 4.1.x
MySQL 3.23.X

After you obtain all the sources, save them all in the same directory as some packages will need access to other packages's sources and it's easier if they're all in the same location.

    /root/apache_24# ls *.gz
    apache_1.3.24.tar.gz
    mm-1.1.3.tar.gz
    mod_perl-1.26.tar.gz
    mod_ssl-2.8.8-1.3.24.tar.gz
    mysql-3.23.44.tar.gz
    openssl-0.9.6c.tar.gz
    php-4.1.2.tar.gz


I wrote a simple Perl script to decompress and untar all of these sources.  You can download it here, or view its source here.  The script can be located anywhere within your path, but it will only untar and decompress the files ending in .tar.gz in the current directory.  It is assumed that you have at least Perl version 5 and are using a UNIX/Linux/BSD system with the gzip and tar utilities installed.

Using the script with Perl:

  # perl untarall

Executing the script from the command line (the script will need to be executable chmod +x untarall)

  # ./untarall

Results of using the untarall script:

 Untared and Decompressed:
  apache_1.3.24.tar.gz
  mm-1.1.3.tar.gz
  mod_perl-1.26.tar.gz
  mod_ssl-2.8.8-1.3.24.tar.gz
  mysql-3.23.47.tar.gz
  openssl-0.9.6c.tar.gz
  php-4.1.2.tar.gz

 /root/apach_24#


Part I    Install MM Shared Memory Library
  1. Change to the source directory for MM:
       # cd  mm-1.1.3
    
  2. To install the MM library into /usr/local/mm/{bin,lib,include,man}/ perform the following steps in your shell:
       # ./configure --prefix=/usr/local/mm
    
  3. Build MM by running:
       # make
    
  4. Test the libraries
       # make test
    
  5. If that works, install the binary with:
       # make install
    
Part II    Install OpenSSL
  1. Change to the source directory for OpenSSL:
       # cd openssl-0.9.6c
    
  2. Run the config script to automatically configure your system
       # ./config no-threads --openssldir=/usr/local/openssl -fPIC
    
  3. Build OpenSSL by running:
       # make
    
  4. After a successful build, the libraries should be tested. Run the following to test them:
       # make test
    
  5. If everything tests OK, install OpenSSL with:
       # make install
    
Part III    Install mod_ssl, mod_perl, and PHP
  1. If you want PHP to have MySQL support, you will have to install MySQLbefore you install PHP.
  2. You should have the Apache, mod_ssl, mod_perl, and PHP sources in the same directory; it'll be easier to configure by doing this.
    *Note that Apache and mod_ssl have the same version (1.3.24)

  3. Apply mod_ssl to the Apache source tree
       # cd mod_ssl-2.8.8-1.3.24
       # ./configure --with-apache=../apache_1.3.24
       # cd ..
    

  4. Apply mod_perl to the Apache source tree and build/install the PERL-side of mod_perl
       # cd mod_perl-1.26
       # perl Makefile.PL \
              EVERYTHING=1 \
              APACHE_SRC=../apache_1.3.24/src \
              USE_APACI=1 \
              PREP_HTTPD=1 \
              DO_HTTPD=1
       # make
       # make install
       # cd ..
    

  5. Configure PHP and apply it to the Apache source tree (*Note the CFLAGS option might fail if your shell is csh, try using bash or sh)
       # cd php-4.1.2
       # CFLAGS='-O2 -I/usr/local/openssl/include' \
         ./configure --with-apache=../apache_1.3.24 \
            --enable-track-vars \
            --with-mysql=/usr/local/mysql \
            --enable-memory-limit=yes \
            --enable-debug=no
       # make
       # make install
    

  6. Copy the php.ini-dist file to /usr/local/lib/php.ini.
       # cp php.ini-dist /usr/local/lib/php.ini
       # cd ..
    

  7. Build/install Apache with mod_ssl, mod_perl, and PHP 4.
       # cd apache_1.3.24
       # SSL_BASE=/usr/local/openssl \
         ./configure \
            --enable-module=so \
            --enable-module=proxy \
            --enable-module=info \
            --enable-module=alias \
            --enable-module=dir \
            --enable-module=userdir \
            --prefix=/usr/local/httpd \
            --enable-module=ssl \
            --enable-module=so \
            --activate-module=src/modules/php4/libphp4.a \
            --activate-module=src/modules/perl/libperl.a
       # make
    

  8. Next you are asked to make a site certificate, the default type is test.  You will be prompted to answer some question about your certificate, it's fine to accept the defaults if you aren't actually installing a certificate from a CA (Certificate Authority).
       # make certificate test
    

  9. If the next step goes correctly you will see a messsage of how to start the server.
       # make install
         [output cut]
       +--------------------------------------------------------+
       | You now have successfully built and installed the      |
       | Apache 1.3 HTTP server. To verify that Apache actually |
       | works correctly you now should first check the         |
       | (initially created or preserved) configuration files   |
       |                                                        |
       |   /usr/local/httpd/conf/httpd.conf
       |                                                        |
       | and then you should be able to immediately fire up     |
       | Apache the first time by running:                      |
       |                                                        |
       |   /usr/local/httpd/bin/apachectl start
       |                                                        |
       | Or when you want to run it with SSL enabled use:       |
       |                                                        |
       |   /usr/local/httpd/bin/apachectl startssl
       |                                                        |
       | Thanks for using Apache.       The Apache Group        |
       |                                http://www.apache.org/  |
       +--------------------------------------------------------+
    

  10. You can now delete all the sources or archive them for future servers.

    I wrote a simple Perl script to delete the source directories.  You can download it here, or view its source here.  In order to use rmalldir, you will have to have used the above untarall script to decompress and untarall the sources since rmalldir only removes directories listed in the dirlist file.  The dirlist file will have to be in the same directory as the directories you want to remove, the rmalldir script can be anywhere in your path.  The untarall script creates this file to track which sources have been decompressed.  It is assumed that you have at least Perl version 5 and are using a UNIX/Linux/BSD system as the rm command is used to delete the directories. Usage of the script is as follows:

    Using the script with Perl:

      # perl rmalldir
    

    Executing the script from the command line (the script will need to be executable chmod +x rmalldir)

      # ./rmalldir
    

    The results of running the rmalldir script:

     /root/apache_24# /root/pbin/rmalldir
     Removed the following dirs:
      apache_1.3.24
      mm-1.1.3
      mod_perl-1.26
      mod_ssl-2.8.8-1.3.24
      mysql-3.23.47
      openssl-0.9.6c
      php-4.1.2
    
     /root/apach_24#
    

  11. If you installed PHP, you will have to edit httpd.conf and uncomment (remove the # symbol from the front of the line) the statements which look like the following:     (around line 765, use the following command vi +765 /usr/local/httpd/conf/httpd.conf to open httpd.conf for editing at line 765)
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
    

  12. Now you can stop the old version of Apache and start the new server.

    Stop the old Apache server as you normally would.  If you don't know how, try the following: (or do ps x | grep httpd at the command line and kill the PID associated with httpd)

      # /etc/rc.d/apache stop
    

    To start the new apache server, use the script created by the install process mentioned in step 9 above.

      # /usr/local/httpd/bin/apachectl start
    

  13. After you start your new server, you can view the available modules with the following command.
       # /usr/local/httpd/bin/httpd -l
       Compiled-in modules:
         http_core.c
         mod_env.c
         mod_log_config.c
         mod_mime.c
         mod_negotiation.c
         mod_status.c
         mod_info.c
         mod_include.c
         mod_autoindex.c
         mod_dir.c
         mod_cgi.c
         mod_asis.c
         mod_imap.c
         mod_actions.c
         mod_userdir.c
         mod_alias.c
         mod_access.c
         mod_auth.c
         mod_proxy.c
         mod_so.c
         mod_setenvif.c
         mod_ssl.c
         mod_php4.c
         mod_perl.c
    
BACK