Setting Up Apache

These are things I like to do when I set up a new Apache 2 server. 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/srcs.
  • 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 --shared
      make install
  • Build Apache. I used the following configuration line:
      ./configure --prefix=/web --enable-module=so --enable-ssl \
                  --enable-dav --with-ssl=/usr/include/openssl --enable-rewrite
      make certificate TYPE=custom
      make install
  • Install mysql and related repositories. I'm using Fedora, so I use yum. If you're using another distro, you'll need to figure out how to install packages (try apt-get).
     sudo yum install mysql-server
     sudo yum install mysql
     sudo yum install mysqlclient
     sudo yum install mysql-devel
    Use chkconfig to make sure that mysqld starts up. Also, amek sure that can be found by ensuring the directory where its located is in /etc/ and then running /sbin/ldconfig.
  • Build the graphics libraries that PHP likes. Many of these may already be installed.
    • Build libjpeg and install in /usr/local (
    •   ./configure
        make install
        make install-lib
    • Build libpng (
        cp scripts/makefile.linux ./Makefile
        make install
        make install-headers
    • Build GD library
        make install
  • 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=/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-gd --enable-bcmath
      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).
  • On newer Linux distros that are using SELinux, you have to tell SELinux to allow the PHP module to load:
       sudo chcon -t texrel_shlib_t /web/modules/
  • 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 to check it.
  • Build the following PERL libraries using CPAN:
    • XML::Parser
    • LWP::UserAgent

Last Modified: Thursday, 31-Mar-2005 19:32:46 UTC