Apache

Installation instructions for using PHP with the Apache web server.

Compiling and Installing
Configure PHP with the options you want. In this case, we'll be adding Apache

./configure \
--with-config-file-path=/usr/local/etc/ \
--enable-fpm \
--enable-pdo \
--enable-mbstring \
--with-curl \
--with-bz2 \
--with-zlib \
--enable-gd \
--with-openssl \
--enable-opcache \
--with-apxs2=/usr/local/apache2/bin/apxs \

Configuration options:

  • Datase support:

    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
  • LDAP support
    --with-ldap
  • Curl support (required by Drupal's Feeds module)
    --with-curl

    Probably need to install curl-devel package first though:

    yum install curl-devel
  • Zlib for file compression support:
    --with-zlib

If it configures correctly, make and install the binaries:

make
make install

Copy the included .ini file to the proper location:

cp php.ini-production /usr/local/lib/php.ini

Edit your httpd.conf to load the PHP module. The path on the right hand side of the LoadModule statement must point to the path of the PHP module on your system. The make install from above may have already added this for you, but be sure to check.

LoadModule php5_module modules/libphp5.so

Tell Apache to parse certain extensions as PHP. For example, let's have Apache parse the .php extension as PHP. You could have any extension(s) parse as PHP by simply adding more, with each separated by a space. We'll add .phtml to demonstrate.

AddType application/x-httpd-php .php .phtml

It's also common to setup the .phps extension to show highlighted PHP source, this can be done with:

AddType application/x-httpd-php-source .phps

Add index.php to the DirectoryIndex option:

DirectoryIndex index.html index.php

Restart the Apache server. Since we are running it under daemontools:

svc -t /service/apache

Performance Tuning
Tuning Apache and PHP for Speed

Recent Updates

  • 5 months 1 week ago
  • 5 months 1 week ago
  • 5 months 1 week ago
    php 8.x
  • 5 months 1 week ago
    10.6.7
  • 5 months 2 weeks ago
    Drop Centos 5/6 stuff