There is two ways to install Apache Http server on Ubuntu :

  1. Use apt command to install it automatically.
  2. Configure and build the source code, and install it manually.

1. Install it automatically

1. Search Apache package with “apt-cache search” command

apt-cache search apache

2. Get Apache package name “apache2″, issue the “apt-get” install command. You need “sudo” privileged for this installation.

sudo apt-get install apache2

3. Done, run your favor internet browser, e.g firefox or IE. Type “http://localhost” in your browser’s URL text box.

4. If you see the words “It work!” in your browser, it means Apache is installed on Ubuntu successfully.

Where is Apache Http server installed?
Issue a “find” command to reveal all the Apache folders and files location.

mkyong@mkyong-desktop:~$ sudo find / -name apache2
/var/lock/apache2
/var/run/apache2
/var/log/apache2
/var/cache/apache2
/usr/sbin/apache2
/usr/lib/apache2
/usr/share/doc/apache2
/usr/share/doc/apache2.2-common/examples/apache2
/usr/share/apache2
/usr/share/bug/apache2
/etc/default/apache2
/etc/logrotate.d/apache2
/etc/cron.daily/apache2
/etc/init.d/apache2
/etc/apache2

2. Install it manually

1. Download Apache Http server from Apache website (e.g httpd-2.2.13.tar.gz)

2. Unzip it with “tar” command.

tar xvfz httpd-2.2.13.tar.gz

3. Configure the folder location with “./configure” command.

 ./configure --prefix=/usr/local/apache --enable-shared=max
Note
The option –prefix is indicate the path where the server will installed, and –enable-shared is activated the load module support, it’s better to turn it on during installation stage for the future extend or customize the functionality without recompiling the server.

4. Build it with “make” command.

make

5. Install it with “install” command, you need “sudo” privileged for this installation.

sudo make install

6. Done, all the Apache http server’s files and folders are located at /usr/local/apache.

Should you install it manually or automatically?

This is really depend on your needs, and also your expertise. The “apt-get” command allocate all the folders structure properly, create start scripts in init.d file and configured many post-installation settings automatically. If you are lazy and do not care about the folder structure, then this is definitely the best choice to go.

However if you want to customize the Apache folder structure during the installation and need full control of what happened in your machine, the manual ways is what you need. For me.. the lazy apt-get install is the faster way to go :)

Tags :
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

Related Posts

Popular Posts