Set up Apache on Ubuntu
- Resources:
- ubuntu distribution has quite different from Fedora Core distribution in terms of apache configurations support and arrangement. It is provided additional commands such as a2ensite (a2dissite) and a2enmod (a2dismod), to facilitate the managing of additional sites and modules.
- ubuntu also by default does not allow root access and users need to access with their individual account (a good practice).
- We have set up a csnet account on the virtual machine with ubuntu OS. Password is the same and announced in class. It is the first user and allow to run sudo command or use sudo bash to a root shell.
- Editing a load balanca (lb) site:
- Enable the chowlb site:
- root@chowdip:/etc/apache2/sites-available# a2ensite chowlb
Enabling site chowlb.
To activate the new configuration, you need to run:
service apache2 reload
root@chowdip:/etc/apache2/sites-available# service apache2 reload
Syntax error on line 41 of /etc/apache2/sites-enabled/chowlb:
Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
- The reason is mod_proxy module is not included in /etc/apache2/mods-enabled directory
- Apply "a2enmod proxy" to create soft links of proxy.conf and prox.load from mods-enabled to mods-available directory
- Apply "a2enmod proxy_balancer" to create soft links fo proxy_balancer.conf and prox_balancer.load from mods-enabled to mods-available directory
- root@chowdip:/etc/apache2# a2enmod proxy_balancer
Considering dependency proxy for proxy_balancer:
Module proxy already enabled
Enabling module proxy_balancer.
To activate the new configuration, you need to run:
service apache2 restart
- service apache2 restart
- Access chowdip.csnet.uccs.edu get "Internal Server Error".
- The error.log in /var/log/apache2 (note that the path and filenames are different than those in fedora!) shows:
[Tue Mar 27 11:14:47 2012] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
- Further examine the mod-availables, we found there is proxy_http.load not included. To include proxy_httpd.load submodules, we run "a2enmod proxy_http" and it solves the problem.
- The access of http://chowdip.csnet.uccs.edu shows that its was served by the web server instead rotating through those of rs1, rs2, and rs3. The reason is /etc/apache2/sites-enabled includes both 000-default and chowlb and 000-default will be the first to be loaded.
- By changing the chowlb to 000-chowlb and 000-default to 001-default, we enable chowlb configuration to overwrite that of original default.
- Now reload "http://chowdip.csnet.uccs.edu" a few times and you will see it shows rs1, rs2, rs3 rotating to service the web page.