Skip to content

Instantly share code, notes, and snippets.

@algotrader-dotcom
Last active December 1, 2022 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save algotrader-dotcom/07b376a7ad5d12ac4456 to your computer and use it in GitHub Desktop.
Save algotrader-dotcom/07b376a7ad5d12ac4456 to your computer and use it in GitHub Desktop.
Compile apache 2.4 + php from source
1. Requirements
yum install pcre*
yum install libxml*
yum install gdbm-devel
2. Download packages
apr-1.5.2.tar.gz
apr-util-1.5.2.tar.gz
php-5.6.14.tar.gz
httpd-2.4.16.tar.gz
3. Install Apache
mv apr-1.5.2 /usr/src/httpd-2.4.16/srclib/apr
mv apr-util-1.5.2 /usr/src/httpd-2.4.16/srclib/apr-util
./configure --prefix=/opt/apache24 \
--enable-so \
--enable-cgi \
--enable-info \
--enable-rewrite \
--enable-speling \
--enable-usertrack \
--enable-deflate \
--enable-ssl \
--enable-mime-magic \
--with-included-apr
make && make install
4. Install PHP
./configure --with-apxs2=/opt/apache24/bin/apxs --with-mysql --prefix=/opt/apache24/php --with-config-file-path=/opt/apache24/php --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm --enable-pdo=shared --with-pdo-mysql=shared --without-pdo-sqlite
make && make install
cp php.ini-production /opt/apache24/php/php.ini
Update php.ini
include_path = "/opt/apache24/php/lib/php"
extension = mysql.so
extension = mysql_pdo.so
5. Re check
/opt/apache24/bin/httpd -M
/opt/apache24/bin/httpd -t
Update httpd.conf:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
DirectoryIndex index.html index.php
AddType text/html .php
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Include conf/extra/httpd-vhosts.conf
6. Start service
/opt/apache24/bin/apachectl start
7. Troubleshooting
# Apache2: AH01630: client denied by server configuration
<VirtualHost *:80>
...
<Directory "/var/www/html/example.com/public">
Options MultiViews FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
...
</VirtualHost>
# ..
8. Install php modules
# memcache
wget http://pecl.php.net/get/memcache-2.2.4.tgz
tar -zxvf memcached-2.2.4.tgz
cd memcached-2.2.4
/opt/apache24/php/bin/phpize
./configure --enable-memcache --with-php-config=/opt/apache24/php/bin/php-config
make && make install
Update php.ini with extension = memcache.so
9. References
http://dan.drydog.com/apache2php.html
http://moiseevigor.github.io/software/2015/05/18/apache2-ah01630-client-denied-by-server-configuration/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment