Installing on Centos 7.1: Apache 2.4.x (https) / MariaDB 5.5 / PHP 5.6.x / OpenSSL 1.0.1x

April 10, 2015

I composed these instructions from notes taken during a recent installation. I cannot guarantee their accuracy because there was a lot of troubleshooting involved and I did not repeat the process. MariaDB (MySQL) and OpenSSL are installed as RPMs; Apache and PHP are compiled from source.

We begin by installing an SSL-related RPM. If OpenSSL itself isn't already installed, append "[space]openssl"

yum install openssl-devel

Next, we install two Apache prerequisites:

yum install apr-util-devel pcre-devel

Download Apache 2.4.x, unpack, configure, compile and install. I chose to add CGI and mod_rewrite:

gzip -dc httpd-2.4.10.tar.gz | tar xvf -
cd httpd-2.4.10
./configure --enable-ssl --enable-cgid --enable-rewrite --enable-so
make install

Generate a private key, CSR and certificate respectively:

openssl genrsa -aes256 -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

In /usr/local/apache2/conf/httpd.conf, uncomment the following lines:

LoadModule ssl_module modules/
LoadModule socache_shmcb_module modules/
Include conf/extra/httpd-ssl.conf

If you'd like virtualhosts, CGI and mod_rewrite, uncomment the following as well:

Include conf/extra/httpd-vhosts.conf
LoadModule vhost_alias_module modules/
LoadModule cgid_module modules/
LoadModule rewrite_module modules/

Still in httpd.conf, set the ServerName variable

I place my virtualhosts in /www, so I added the following to httpd-vhosts.conf:

<Directory /www>
Require all granted

In httpd-ssl.conf, adjust the following variables to meet your needs:


Install a PHP prerequisite:

yum install libxml2-devel

Download PHP 5.6.x, unpack, configure, compile, test and install:

gzip -dc php-5.6.7.tar.gz | tar xvf -
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make test
make install

Install Perl and CGI:

yum install perl-CPAN perl-local-lib
perl -MCPAN -e shell
[follow the inititial setup, accepting defaults unless otherwise desired]
install CGI

I like to use htpasswd, so I installed it and created a new .htpasswd file:

yum install \*bin/htpasswd
htpasswd -c .htpasswd [username]

To start Apache and MariaDB, we run:
/usr/local/apache2/bin/apachectl start
systemctl start mariadb.service