How to install Apache from source code

To install the latest version of Apache Web Server from source code, go to the apache website, download the latest source code .tar.gz file.

At the time of writing this, the latest version was Apache HTTP Server 2.4.52.

cd /usr/local/src
wget --no-check-certificate
tar xvf httpd-2.4.52.tar.gz
cd /usr/local/src/httpd-2.4.52
./configure --prefix=/usr/local/apache --enable-proxy --enable-proxy-connect --enable-proxy-fcgi --enable-remoteip
make install

If you get an error related to APR

checking for APR... no
configure: error: APR not found.  Please read the documentation.

Install APR with


yum -y install apr-devel apr-util-devel

For Ubuntu/Debian

apt install libapr1-dev libaprutil1-dev libpcre3-dev build-essential

To start Apache, use the command

/usr/local/apache/bin/apachectl start

To stop

/usr/local/apache/bin/apachectl stop

Apache config files are located at


Create Apache Service file


Create file

vi /usr/lib/systemd/system/apache2.service

With the following content

Description=The Apache HTTP Server

ExecStart=/usr/local/apache/bin/apachectl start
ExecReload=/usr/local/apache/bin/apachectl graceful
ExecStop=/usr/local/apache/bin/apachectl graceful-stop


Enable and start Apache service with

systemctl daemon-reload
systemctl enable apache2
systemctl restart apache2

To enable Apache module, you can edit file /usr/local/apache/conf/httpd.conf

Here are sed commands to enable some common apache modules

sed -i 's/^#LoadModule proxy_module/LoadModule proxy_module/g'  /usr/local/apache/conf/httpd.conf
sed -i 's/^#LoadModule proxy_fcgi_module/LoadModule proxy_fcgi_module/g'  /usr/local/apache/conf/httpd.conf
sed -i 's/^#LoadModule ssl_module/LoadModule ssl_module/g'  /usr/local/apache/conf/httpd.conf
sed -i 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g'  /usr/local/apache/conf/httpd.conf
Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *