Howto install Apache with ModSSL and PHP from source

Code:

# choose a source dir:
cd /usr/local/src
# there are lots of mirrors, get apach_1.3.33.tar.gz from one of them
# you can get a random mirror at http://httpd.apache.org/download.cgi
# here is one for your convenience:

wget http://government-grants.org/mirrors/apache.org/httpd/apache_1.3.33.tar.gz
#get latest openssl:
wget http://www.openssl.org/source/openssl-0.9.7g.tar.gz
# get modssl:
wget http://www.modssl.org/source/mod_ssl-2.8.22-1.3.33.tar.gz
# get php, lots of mirrors http://www.php.net/downloads.php
# here is one for your convenience:
wget http://us3.php.net/get/php-5.0.4.tar.gz/from/this/mirror

# untar:
tar -xzf apache_1.3.33.tar.gz
tar -xzf mod_ssl-2.8.22-1.3.33.tar.gz
tar -xzf openssl-0.9.7g.tar.gz
tar -xzf php-5.0.4.tar.gz

# install openssl:
cd openssl-0.9.7g
./config
make
make install
cd ..

#ready apach with modssl:
cd mod_ssl-2.8.22-1.3.33
./configure –with-apache=../apache_1.3.33
cd ..

# install apache:
cd apache_1.3.33
make clean
SSL_BASE=”/usr/local/ssl” ./configure –prefix=/etc/httpd –enable-module=headers –enable-module=ssl –enable-module=so –enable-module=rewrite –disable-rule=SSL_COMPAT
make
make install
cd ..

# install PHP:
cd php-5.0.4
# assume you have installed MySQL libraries via RPM:
./configure –with-config-file-path=/etc/httpd/conf –with-apxs=/etc/httpd/bin/apxs –with-mysql=/usr
make
make install

cat php.ini-dist > /etc/httpd/conf/php.ini

# this is optional, but my favorites are:

# turn on PHP4 object handling mode:
sed -e ‘s/zend.ze1_compatibility_mode = .*/zend.ze1_compatibility_mode = On/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/expose_php = .*/expose_php = Off/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/max_execution_time = .*/max_execution_time = 300/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/memory_limit = .*/memory_limit = 256M/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/display_errors = .*/display_errors = Off/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/log_errors = .*/log_errors = On/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/log_errors_max_len = .*/log_errors_max_len = 2048/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/post_max_size = .*/post_max_size = 128M/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/upload_max_filesize = .*/upload_max_filesize = 128M/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/default_socket_timeout = .*/default_socket_timeout = 30/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/magic_quotes_gpc = .*/magic_quotes_gpc = Off/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/session.gc_divisor *=.*/session.gc_divisor = 1000/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

sed -e ‘s/session.gc_maxlifetime *=.*/session.gc_maxlifetime = 21600/’ /etc/httpd/conf/php.ini > /tmp/php.ini
cat /tmp/php.ini > /etc/httpd/conf/php.ini

# start the server:
/etc/httpd/bin/apachectl sslstart

# but you’ll need to ready your HTTP.conf file and get your SSL keys in place first.
# See other posts on this board for help with that.

Comments are closed.