Setting Up Apache for 64-Bit Linux

These are things I like to do when I set up a new Apache server. This version (see the original) is for Apache 2.X on a 64-bit Xeon server. There are some small differences caused by the 64-bit processor.

For ideas on setting up software RAID, a serial console, SAMBA, and configuring Linux, see my topic guide on setting up a Linux server.

  • Decide what user you want to own the Apache installation. Suppose its web. Create user web with the directory /web as its home. Become web for the rest of this. You'll need to use sudo to do some of the installations and start and stop the web server.
  • Download Apache, PHP, OpenSSL, cronolog, and any other modules you need. I untar all of these in the same top-level directory, usually /web/src.
  • Make and install cronolog first.
  • Make and install the latest OpenSSL. The one that comes with your distro is probably out of date and you need the source tree anyway for mod_ssl. If openssl is already installed on your machine, take care to overwrite the old version with the new so that you only have one copy.
      ./config --prefix=/usr
      make
      make install
      
  • Apache 2.X comes with mod_ssl, so you don't need to install and build it separately.
  • Build Apache. I used the following configuration line:
     ./configure --prefix=/web --enable-ssl --enable-dav \
         --with-ssl=/usr/include/openssl --enable-rewrite \
         --enable-lib64 --with-expat=builtin
      make
      make certificate TYPE=custom
      make install
      
  • Make sure that the libmysqlclient.so can be found by ensuring the directory where its located is in /etc/ld.so.conf and then running /sbin/ldconfig.
  • I installed MySql using yum:
    yum -y install mysql mysql-server php-mysql 
    
    Make sure mysqld starts running on a reboot by running the command:
    chkconfig mysqld on
    
  • Set up a root password for MySql:
     mysqladmin -u root password 'new-password'   # quotes are required
    
    And then log in and do some housekeeping:
    mysql -u root -p
    
    mysql> DROP DATABASE test;                            
    mysql> DELETE FROM mysql.user WHERE user = '';        
    mysql> FLUSH PRIVILEGES;
    
  • Build and install the following Perl modules (your list might vary):
    • XML::Parser (required for MT)
    • Crypt::DSA
  • Build libjpeg and install in /usr/local (http://freshmeat.net/projects/libjpeg/)
    ./configure
    make
    make install
    make install-lib
    
  • Build libpng (http://www.libpng.org/pub/png/libpng.html)
    cp scripts/makefile.linux ./Makefile
    make
    make install
    make install-headers
    
  • Build GD library
    ./configure
    make
    make install
    
  • Build mod_fastcgi (if you're using it). I needed this patch to make it build.
  • http://www.deanspot.org/~alex/php5fcgi/index.html
  • Build PHP. I use the following:
      ./configure --prefix=/web --with-apxs=/web/bin/apxs \
                  --with-config-file-path=/web/lib/ --with-zlib \
                  --with-ttf --with-mysql=shared,/usr \
                  --with-mysql-sock=/var/run/mysqld/mysqld.sock \
                  --disable-rpath --disable-ipv6 --enable-static \
                  --enable-roxen-zts --enable-track-vars \
                  --enable-force-cgi-redirect --with-gettext --with-apxs \
                  --with-gd --enable-bcmath
      make
      make install
    
  • Make sure php.ini is installed in /web/lib. Be sure to change the max_file_upload_size parameter to 10 (default is 2).
  • Update the httpd.conf file.
    1. Set up logging using cronolog
          ErrorLog "|/usr/local/sbin/cronolog /web/logs/%Y/%m/%d/errors.log"
          CustomLog "|/usr/local/sbin/cronolog /web/logs/%Y/%m/%d/access.log" combined
          
    2. Ensure PHP is configured right by testing it (the installation should do this automatically).
    3. Add index.php and any others to the Indexes directive.
    4. Read the SSL configuration file.
  • Change /etc/init.d/httpd so that it starts the Apache you installed, rather than the default (if any).
  • Reboot and test to check that everything comes up and works.

Last Modified: December 30, 2006