Download the latest version of the Apache web server. At the time of writing, the current version was 2.4.16.

cd /extra/src
wget http://apache.mirror.vexxhost.com//httpd/httpd-2.4.17.tar.gz
tar zxf httpd-2.4.17.tar.gz
cd httpd-2.4.17

Download the latest versions of APR and APR-Util:

cd srclib
wget http://apache.mirror.gtcomm.net//apr/apr-1.5.2.tar.gz
tar zxf apr-1.5.2.tar.gz
mv apr-1.5.2 apr
wget http://apache.mirror.gtcomm.net//apr/apr-util-1.5.4.tar.gz
tar zxf apr-util-1.5.4.tar.gz
mv apr-util-1.5.4 apr-util
cd ..

In order to secure parts of our website, we'll enable mod_ssl. Compiling mod_rewrite is useful for rewriting URLs. Drupal, in particular, makes use of this.

./configure --enable-so --enable-ssl --enable-rewrite

If all configures correctly, make and install the binaries:

make install

Edit /usr/local/apache2/conf/httpd.conf and change the user and group from daemon to nobody:

User nobody
Group nobody

CentOS 7 Firewall settings:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload

Confirm that Apache starts up correctly, then stop it again:

/usr/local/apache2/bin/apachectl start
/usr/local/apache2/bin/apachectl stop

Automatic Startup
There's a number of different ways to get Apache to start automatically (rc.d/init.d script, rc.local, xinetd). We're going to use daemontools.
If you haven't already, install daemontools.

Create a directory for the Apache service:

mkdir -m 1755 /var/service/apache
cd /var/service/apache

Create the run script and make it executable:

echo '#!/bin/sh' > run
echo 'exec 2>&1' >> run
echo 'exec /usr/local/apache2/bin/httpd -DNO_DETACH 2>&1' >> run
chmod 755 run

Our log script comes from John Simpson's:

mkdir -m 755 log
cd log
wget http://qmail.jms1.net/scripts/service-any-log-run
mv service-any-log-run run
chmod 755 run

Finally, add the service to daemontools by creating the symbolic link in /service

ln -s /var/service/apache /service/apache

Confirm that the service is running:

svstat /service/apache /service/apache/log

Securing Apache

Recent Updates

  • PHP
    1 year 7 months ago
    PHP 7.4
  • 1 year 7 months ago
    MariaDB 10.4.12
  • 1 year 7 months ago
    Dovecot 2.3.10
  • 1 year 7 months ago
    CentOS 6 revisions
  • 1 year 7 months ago
    Copy of the revision from Wed, 08/22/2018 - 13:39.