Install Apache 2.2.22 on Ubuntu 14.04

I managed to install it running the following command.

sudo apt-get install apache2=2.2.22-1ubuntu1.7 apache2.2-common=2.2.22-1ubuntu1.7 apache2.2-bin=2.2.22-1ubuntu1.7 apache2-mpm-worker=2.2.22-1ubuntu1.7

Thanks to this question here

Update: It seems like 2.2.22-1ubuntu1.7 does not exist any more. Please try using 2.2.22-1ubuntu1.10

With my original question I have since found the original problem while downgrading so did not look into this problem any further since then.


How to install Apache 2.2 on an Ubuntu distro that does not have it in the repositories.

Requirements

You need to have the build-essentials package installed to do this.

~# sudo apt-get install build-essential

To give Apache the ability to compress output to browsers that support it, you need to install zlib. Download the current release from the zlip Hompage (zlib-1.2.11.tar.gz as of writing), extract it, navigate to the extracted folder, build, and install.

wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure --prefix=/usr/local
make
sudo make install

Install Apache 2.2

Download the curent version from the Apache Download Page (httpd-2.2.32.tar.gz as of writing), extract it, navigate to the extracted folder, build, and install.

wget http://www-eu.apache.org/dist/httpd/httpd-2.2.32.tar.gz
tar -xvf httpd-2.2.32.tar.gz
cd httpd-2.2.32/
./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http
make
sudo make install

Start Apache:

sudo /usr/local/apache2/bin/apachectl start

Check, if everything is OK

Navigate to http://localhost in your browser, where you should see a message saying “It works!”.

Alterntively, you can do this via terminal:

wget -qO- http://localhost | grep "It works!"

Which should output something like this in the terminal:

<html><body><h1>It works!</h1></body></html>

Make Apache start at boot time

sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
sudo chmod +x /etc/init.d/apachectl
sudo sed -i '2i #\n### BEGIN INIT INFO\n# Provides:             apache2\n# Required-Start:       $remote_fs\n# Required-Stop:        $remote_fs\n# Default-Start:        2 3 4 5\n# Default-Stop:         0 1 6\n# Description:          apache2\n# Short-Description:    The Apache webserver\n### END INIT INFO' /etc/init.d/apachectl
sudo /usr/sbin/update-rc.d apachectl defaults

Hint: you can call apachectl with sudo service apachectl now.

Secure Apache

sudo service apachectl stop
sudo adduser --system apache
sed -i -e 's/User daemon/User apache/g' /usr/local/apache2/conf/httpd.conf
sed -i -e 's/Group daemon/Group nogroup/g' /usr/local/apache2/conf/httpd.conf
sudo service apachectl start

Check new settings

ps -aux | grep httpd

If the terminal output of the last command shows some lines starting with "apache" then everything is OK.

Configure your site(s)

If you want to configure your apache for just one site, simply edit the httpd.conf

nano /usr/local/apache2/conf/httpd.conf

The essential parameters you may want to modify are:

ServerName www.example.com:80
DocumentRoot "/usr/local/apache2/htdocs"

<Directory "/usr/local/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

If you want to configure more than one site, have a look at httpd-vhosts.conf

nano /usr/local/apache2/conf/extra/httpd-vhosts.conf

You will have to add a < Directory > section withing the < VirtualHost > similar to the one above, but for the document root of the VitualHost. For example:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/usr/local/apache2/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
    <Directory "/usr/local/apache2/docs/dummy-host.example.com">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Tags:

Apache2

14.04