Apache2

Apache2 is an opensource web server that will run on many operating systems. Linux is probably the most common platform for running Apache2.

Useful code

VirtualHost Example

for setting up a virtual host that will handle a primary domain as well as an alias

<VirtualHost *:80>
ServerName yourdomain
ServerAlias aliasdomain
DocumentRoot /var/www/html
</VirtualHost>

Apache Password Protection

To use Apache to password protect a site you can set the following lines in the .htaccess file for the site

AuthUserFile /home/user/.htpasswd
AuthType Basic
AuthName “Guest”
Require valid-user

 

The following command will generate a .htpasswd file and request the password that will be set

htpasswd -c /home/user/.htpasswd