Apache is the world’s most popular web server, and is developed and maintain by an open community of developers under the Apache Software Foundation.
Installing Apache for Ubuntu
From the Ubuntu desktop:
- Go to System > Administration > Synapatic Package Manager
- Search for “apache2″ and “Mark for installation”
- Click on the “Apply” to install
From the command line:
$ sudo apt-get install apache2
Apache Directories for Ubuntu
/etc/apache2This directory contains the Apache configuration files./etc/init.dThe startup scriptapache2can be found in this directory. This script is used to start and stop the server. It also, automatically starts and stops the server when it’s halted, started, or rebooted./var/wwwThe default location for the web content./usr/sbinThe executable programs are placed in this directory. For example:apache2the server executeable itself./usr/binSome of the utilities from Apache package are placed here. For example:htpasswd, used for generating authentication password files.
Configuration Files
The configuration files for Apache is under the directory /etc/apache2.
apache2.confThis is the file which contains all the default configurations of the web server. Inside the configuration file it also loads configurations from:mods-enabled/*.load,mods-enabled/*.conf,httpd.conf,ports.conf,conf.d/, andsites-enabled/mods-availableThis directory contains all the configurations for all the available modules in Apachemods-enabledThis directory contains all the configurations for the modules enable in Apachehttpd.confThis file is original and should contain custom configuration specifically for your web server. e.g. ServerNameports.confThis file contains a list of all the ports the web server should be listening to.sites-availableThis directory should contain all the configurations for your websites being hosted on the webserversites-enabledThis directory should contains the configurations for your websites that you have enabled on the web server.
Starting and Stopping Apache
The /etc/init.d/apache2 script and the following options is use to control the web server:
startStart the web server.stopStops the web server.reloadReload the configuration files after modification.restartConvenient way to stop and then immediately start the web server.
Virtual Hosting
Virtual hosts enable you to run more than one host on the same IP address. To enable virtual host you can modified the httpd.conf file:
NameVirtualHost 192.168.100.1
<VirtualHost 192.168.100.1>
ServerName www.vincentkong.com
ServerAlias vincentkong.com
CustomLog /path/to/logfile/access.log combined
ErrorLog /path/to/logfile/error.log
DocumentRoot /path/to/website/
<Directory /path/to/website/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
allow from all
</Directory>
</VirtualHost>
Options Directives
Options directives determines what options are available for the directory configured in Apache.
| Switch | Description |
None |
None of the available options are enabled for this directory. |
All |
All the options, except for MultiViews, are enabled for this directory. |
Indexes |
If the index.html or other DirectoryIndex file is missing, then list the files in the directory as an HTML page. |
Includes |
Server-side includes (SSI) are permitted in this directory. Can also be IncludesNoExec if you want to allow includes but don’t allow exec option. |
FollowSymLinks |
Allows access to directories that are symbolically linked to a document directory. |
ExecCGI |
CGI programs are permitted in this directory. |
MultiViews |
Part of mod_negotiation module. When a client requests document that can’t be found, the server tries to figure out which document best suits the client’s requirements. |
Enabling/Disabling Multiple Sites
There are two commands which allows you to easily enable/disable multiple websites. For each website create a file in the /etc/apache2/sites-available directory (it’s perferable that the file name is the name of your site) e.g. vincentkong.com, and add in your virtual host settings.
To enable the website use the command:
$ a2ensite <site filename>
This command will create a symbolic link inside the /etc/apache2/sites-enabled directory to your file.
To disable the website use the command:
$ a2dissite <site filename>
Enabling/Disabling Modules
All the configuration files for the modules installed with Apache can be found in /etc/apache2/mods-available, the .load file are the settings to load the module, and the .conf are the default settings for the module.
To enable a module for Apache use the following command:
$ a2enmod or
$ a2enmod <module name> (if you already know the name of the module)
This command basically creates a symbolic link in the mods-enabled directory to the module configuration you specified.
To disable a module use the command:
$ a2dismod
Link Summary
Related posts: