5

There are a ton of resources to which none of them are useful on how to install Apache 2.2 from Precise (12.04) on ubuntu trusty (14.04).

Can someone please help with a detailed answer of how to install Apache 2.2 on Ubuntu 14.04.

When I do an apt-cache there is no Apache 2.2.

When I add the sources, I then get Apache 2.2 but trying to install that does not work.

Apache 2.2 dependencies rely on apache2.2-common which relies on apache2.2-bin.

So I tried installing apache2.2-bin --> apache2.2-common --> apache2-mpm-worker then apache2={version}.

But every time after installation it tells me it failed. When I restart it tells me it failed and it could not read something out of the configuration file because it was missing.

Thank you in advance.

4

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.

  • This didn't work for me, I got the following: E: Version '2.2.22-1ubuntu1.7' for 'apache2' was not found – duality_ May 29 '16 at 11:06
  • Did you add sources to 12.04 distribution? – Shane Van Wyk May 29 '16 at 11:08
  • Need to add Ubuntu precise sources and do an update. – Shane Van Wyk May 29 '16 at 11:11
  • I have added the following sources (gist.github.com/rokcarl/d9299393721214646e8fbe92ee25595c) to /etc/apt/sources.list and ran sudo apt-get update && sudo apt-get upgrade before trying this command. I'm on 14.04 though. – duality_ May 29 '16 at 11:18
  • 1
    @BraianMellor You might need to find the versions available on ubuntu's website, I know its frustrating when these post's do no work anymore due to the time that has passed. there was most likely a upgrade or downgrade on 2.2 which gives it a new number, You can try and see if there is 2.2.22-1ubuntu1.9 available. – Shane Van Wyk Aug 8 '17 at 1:20
2

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 webmaster@dummy-host.example.com
    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>
  • Hey Johano, this is an excellent tutorial; thank you so much for sharing this. I have one question about configuring httpd-vhosts.conf. In your instructions below this part, you write the command as: nano /usr/local/apache2/conf/httpd.conf. Did you mean to write nano /usr/local/apache2/conf/httpd-vhosts.conf? If so, this file does not exist after completing installation and needs to be created. – MattSidor Jul 25 '17 at 4:23
  • 1
    Upon further research, I think the correct path for this file is /usr/local/apache2/conf/extra/httpd-vhosts.conf. I will edit your post to reflect this. – MattSidor Jul 26 '17 at 21:17
  • 1
    Hi Matt, sorry I missed your question. Thanks for correcting the path. – Johano Fierra Oct 13 '17 at 21:39
0

How to install Apache 2.2.34 (Ubuntu 14.04.x ... 16.04.4 or later):

1. Install new zlib:

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

2. Install apache 2.2.34:

wget http://archive.apache.org/dist/httpd/httpd-2.2.34.tar.gz

tar -xvf httpd-2.2.34.tar.gz

cd httpd-2.2.34/

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http

make

sudo make install

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

Enjoy !!!

0

As of Feb 2019, I did the following to install Apache 2.2 on Ubuntu 14.04:

Add old Repos to sources.list:

deb http://old-releases.ubuntu.com/ubuntu/ raring main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-updates main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-backports main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse
deb-src http://old-releases.ubuntu.com/ubuntu/ raring-proposed main restricted universe multiverse

Used the command "apt-cache madison ^apache2 | grep "2.22" to find the appropriate version details

Then

  apt install apache2.2=2.2.22-6ubuntu5.1 apache2-mpm-worker=2.2.22-6ubuntu5.1 apache2.2-common=2.2.22-6ubuntu5.1

Commented out the modules not available, and went from there. I note that some of the modules needed to be installed - apt-cache madison ^libapache2 helped find them. Also I have issues with authz - presumably because I was not starting from a clean config.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.