Ubuntu apache server installation

This is a guide on how to install web server in Ubuntu. Ubuntu uses Apache as a web server. In this tutorial, user will learn how to check apache2 package in Ubuntu system before proceed to the apache2 installation itself. Apache2 web server can be installed from binary package or from source. The easiest method is installing apache2 web server from binary package using package management system.

Check apache server in Ubuntu

First, you have to check whether apache has been installed in your system or not. You can use any of the methods shown below:

Example using dpkg command to check apache in Ubuntu:


luzar@ubuntu:~$ sudo dpkg -l | grep apache
ii apache2 2.2.8-1ubuntu0.3 Next generation, scalable, extendable web server
ii apache2-mpm-prefork 2.2.8-1ubuntu0.3 Traditional model for Apache HTTPD
ii apache2-utils 2.2.8-1ubuntu0.3 utility programs for webservers
ii apache2.2-common 2.2.8-1ubuntu0.3 Next generation, scalable, extendable web server
ii libapache2-mod-php5 5.2.4-2ubuntu5.4 server-side, HTML-embedded scripting language
luzar@ubuntu:~$

Example using ps command to check apache service in Ubuntu:


luzar@ubuntu:~$ ps aux | grep apache2
root 4594 0.0 1.3 20460 6748 ? Ss 22:05 0:00 /usr/sbin/apache2 -k start
www-data 5247 0.0 0.6 20460 3376 ? S 22:57 0:00 /usr/sbin/apache2 -k start
www-data 5248 0.0 0.6 20460 3376 ? S 22:57 0:00 /usr/sbin/apache2 -k start
www-data 5249 0.0 0.6 20460 3376 ? S 22:57 0:00 /usr/sbin/apache2 -k start
www-data 5253 0.0 0.6 20460 3376 ? S 22:57 0:00 /usr/sbin/apache2 -k start
www-data 5255 0.0 0.6 20460 3376 ? S 22:57 0:00 /usr/sbin/apache2 -k start
luzar 8448 0.0 0.1 3004 756 pts/0 R+ 23:51 0:00 grep apache2
luzar@ubuntu:~$

Example using aptitude command to search apache package in Ubuntu:


luzar@ubuntu:~$ sudo aptitude search apache2
[sudo] password for luzar:
i apache2 - Next generation, scalable, extendable web
v apache2-dev -
p apache2-doc - documentation for apache2
v apache2-mpm -
p apache2-mpm-event - Event driven model for Apache HTTPD
p apache2-mpm-itk - multiuser MPM for Apache 2.2
p apache2-mpm-perchild - Transitional package - please remove
i apache2-mpm-prefork - Traditional model for Apache HTTPD
p apache2-mpm-worker - High speed threaded model for Apache HTTPD
p apache2-prefork-dev - development headers for apache2
p apache2-src - Apache source code
p apache2-threaded-dev - development headers for apache2
i apache2-utils - utility programs for webservers
i apache2.2-common - Next generation, scalable, extendable web
p gforge-web-apache2 - collaborative development tool - web part
p libapache2-authenntlm-perl - Perform Microsoft NTLM and Basic User Auth
p libapache2-mod-apparmor - changehat AppArmor library as an Apache mo
p libapache2-mod-apreq2 - generic Apache request library - Apache mo
p libapache2-mod-auth-kerb - apache2 module for Kerberos authentication
p libapache2-mod-auth-mysql - Apache 2 module for MySQL authentication
p libapache2-mod-auth-openid - OpenID authentication module for Apache2
p libapache2-mod-auth-pam - module for Apache2 which authenticate usin
p libapache2-mod-auth-pgsql - Module for Apache2 which provides pgsql au
p libapache2-mod-auth-plain - Module for Apache2 which provides plaintex
p libapache2-mod-auth-radius - Apache 2.x module for RADIUS authenticatio
p libapache2-mod-auth-shadow - Apache2 module for authentication using sh
p libapache2-mod-auth-sys-group - Module for Apache2 which checks user again
p libapache2-mod-authnz-external - authenticate Apache against external authe
p libapache2-mod-bt - BitTorrent tracker for the Apache2 web ser
p libapache2-mod-bt-dev - Header files for mod_bt
p libapache2-mod-chroot - run Apache in a secure chroot environment
p libapache2-mod-defensible - module for Apache2 which provides DNSBL us
p libapache2-mod-dnssd - Zeroconf support for Apache 2 via avahi
p libapache2-mod-encoding - Apache2 module for non-ascii filename inte
p libapache2-mod-evasive - evasive module to minimize HTTP DoS or bru
p libapache2-mod-fastcgi - Apache 2 FastCGI module for long-running C
p libapache2-mod-fcgid - an alternative module compat with mod_fast
p libapache2-mod-geoip - GeoIP support for apache2
p libapache2-mod-jk - Apache 2 connector for the Tomcat Java ser
p libapache2-mod-layout - Apache web page content wrapper
p libapache2-mod-ldap-userdir - Apache module that provides UserDir lookup
p libapache2-mod-line-edit - search-and-replace line editor module for
p libapache2-mod-log-sql - Use SQL to store/write your apache queries
p libapache2-mod-log-sql-dbi - Use SQL to store/write your apache queries
p libapache2-mod-log-sql-mysql - Use SQL to store/write your apache queries
p libapache2-mod-log-sql-ssl - Use SQL to store/write your apache queries
p libapache2-mod-macro - Create macros inside apache2 config files
p libapache2-mod-mime-xattr - Apache2 module to get MIME info from files
p libapache2-mod-mono - Apache module for running ASP.NET applicat
p libapache2-mod-musicindex - Browse, stream, download and search throug
p libapache2-mod-neko - Apache module for running server-side neko
p libapache2-mod-perl2 - Integration of perl with the Apache2 web s
p libapache2-mod-perl2-dev - Integration of perl with the Apache2 web s
p libapache2-mod-perl2-doc - Integration of perl with the Apache2 web s
i libapache2-mod-php5 - server-side, HTML-embedded scripting langu
p libapache2-mod-proxy-html - Apache2 filter module for HTML links rewri
p libapache2-mod-python - Apache 2 module that embeds Python within
p libapache2-mod-python-doc - Apache 2 module that embeds Python within
v libapache2-mod-python2.5 -
p libapache2-mod-random - Create random ads, quotes and redirects
p libapache2-mod-removeip - Module to remove IP from apache2's logs
p libapache2-mod-rpaf - module for Apache2 which takes the last IP
p libapache2-mod-ruby - Embedding Ruby in the Apache2 web server
p libapache2-mod-scgi - Apache module implementing the SCGI protoc
p libapache2-mod-shib - Shibboleth implements the OASIS SAML v1.1
p libapache2-mod-speedycgi - apache2 module to speed up perl scripts by
p libapache2-mod-suphp - Apache2 module to run php scripts with the
p libapache2-mod-vhost-hash-alias - Fast and efficient way to manage virtual h
p libapache2-mod-vhost-ldap - Apache 2 module for Virtual Hosting from L
p libapache2-mod-wsgi - Python WSGI adapter module for Apache
p libapache2-mod-xmlrpc2 - XMLRPC Server module for Apache2 web serve
p libapache2-modbt-perl - Perl bindings for mod_bt
p libapache2-modxslt - XSLT processing module for Apache 2.0.x ba
p libapache2-redirtoservname - Apache 2 module to redirect users to the c
p libapache2-request-perl - generic Apache request library - Perl modu
p libapache2-svn - Subversion server modules for Apache
p libapache2-webauth - Apache 2 modules for WebAuth authenticatio
p libapache2-webkdc - Apache 2 modules for a WebAuth authenticat
p php5-apache2-mod-bt - PHP bindings for mod_bt
p rt3.6-apache2 - Apache 2 specific files for request-tracke
p torrus-apache2 - Universal front-end for Round-Robin Databa
luzar@ubuntu:~$

All the results above shown that apache is already installed in my system. If you didn't have apache yet, then you can install apache with a guide below.

Install apache server in Ubuntu

You can use any package management system in Ubuntu to install apache package. Ubuntu has two package management systems, apt and aptitude. However, apt is the most popular package management system and used by many system administrator. You can used any package management tool but it's recommended you stick with one that you are comfortable with.

Install apache package with apt-get command

Apt-get can be used to install, upgrade or remove package. This is an example of how to use apt-get command to install apache2 package:


sudo apt-get install apache2

Install apache package with aptitude command

Aptitude is the latest package management system developed for Debian. Ubuntu does not include aptitude in its official distribution. However, user can install aptitude using apt-get if they want aptitude in their system. Example using aptitude command to install apache2 package:


sudo aptitude install apache2