Skip to content

Instantly share code, notes, and snippets.

@ferodss
Last active April 10, 2016 17:29
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ferodss/5762620 to your computer and use it in GitHub Desktop.
Save ferodss/5762620 to your computer and use it in GitHub Desktop.
Compile Apache 2.4.4 with SSL, FastCGI and PHP 5.4 as FPM on CentOS for Magento store
### ADD RPM Forge repository
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm # Verifies the package
rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
### APACHE
# Dependencies
yum install apr-devel apr-util-devel gcc pcre-devel.x86_64 zlib-devel openssl-devel libtool
# Downloa Apache
wget -c http://ftp.unicamp.br/pub/apache//httpd/httpd-2.4.4.tar.gz
tar xvfz httpd-2.4.4.tar.gz
# APR and APR-Util dependencies
cd httpd-2.4.4/srclib
wget -c http://www.gtlib.gatech.edu/pub/apache/apr/apr-1.4.6.tar.gz
wget -c http://www.gtlib.gatech.edu/pub/apache/apr/apr-util-1.5.2.tar.gz
tar xvfz apr-1.4.6.tar.gz
tar xvfz apr-util-1.5.2.tar.gz
mv apr-1.4.6 apr
mv apr-util-1.5.2 apr-util
# Configure and install
./configure --enable-so \
--enable-deflate \
--enable-expires \
--enable-rewrite \
--enable-ssl \
--disable-autoindex \
--with-included-apr \
--with-included-apr-util
make && make install
# Add apache bins to $PATH
# add to ~/.bash_provile
PATH=$PATH:/usr/local/apache2/bin
# Enable SSL
# uncomment lines
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule actions_module modules/mod_actions.so
Include conf/extra/httpd-ssl.conf
# Install mod_fastcgi
cd /usr/local/src
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar zxvf mod_fastcgi-current.tar.gz
cd mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
# To complie in Apache 2.4, we need a patch
# @link https://github.com/ByteInternet/libapache-mod-fastcgi
wget https://raw.github.com/ByteInternet/libapache-mod-fastcgi/byte/debian/patches/byte-compile-against-apache24.diff
patch -p1 < byte-compile-against-apache24.diff
# Now compile =)
make && make install
# In httpd.conf add
LoadModule fastcgi_module modules/mod_fastcgi.so
### PHP-FPM
# Install dependencies
yum install libmcrypt-devel libxml2-devel bzip2-devel libcurl-devel readline-devel
# Downlod current stable version, in my case, PHP 5.4.16
wget -c http://www.php.net/get/php-5.4.16.tar.gz/from/br1.php.net/mirror
tar zxvf php-5.4.16.tar.gz
cd php-5.4.16
# Check Magento requirements in http://www.magentocommerce.com/system-requirements
./configure --prefix=/usr/local/php \
--enable-fpm \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mcrypt \
--with-mhash \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-libxml-dir=/usr \
--with-iconv \
--with-curl \
--enable-soap \
--with-readline \
--enable-exif \
--enable-calendar \
--enable-bcmath \
--with-zlib \
--with-zlib-dir=/usr \
--with-bz2 \
--enable-zip \
--enable-mbstring \
--with-gettext \
--with-openssl \
--with-freetype-dir=/usr
# Now compile and go drink a coffe =)
make && make install
# PHP Config & CGI bin
cp php.ini-production /usr/local/php/lib/php.ini
cp sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/bin/php-cgi /usr/local/apache2/cgi-bin/
# Edit /etc/init.d/php-fpm
...
prefix=
exec_prefix=
php_fpm_BIN=/usr/local/php/sbin/php-fpm
php_fpm_CONF=/usr/local/php/etc/php-fpm.conf
php_fpm_PID=/var/run/php-fpm.pid
...
# Add to the end of httpd.conf
<IfModule mod_fastcgi.c>
ScriptAlias /fcgi-bin/ "/usr/local/apache2/cgi-bin/"
FastCGIExternalServer /usr/local/apache2/cgi-bin/php-cgi -host 127.0.0.1:9000 -pass-header Authorization
AddHandler php-fastcgi .php
Action php-fastcgi /cgi-bin/php-cgi
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment