Apache

From Wiki
Jump to navigation Jump to search

server-side includes

To enable server side includes under Ubuntu Apache2:

  1. In /etc/apache2/mods-available/dir.conf, add index.shtml to list of directories
  2. In /etc/apache2/mods-enabled, create a link to ../mods-available/include.load
  3. In /etc/apache2/sites-available/default, add the Includes directive to the Options state in the Directory /var/www/ section.

password-protected directory

Create a directory entry in your site definition file (e.g. /etc/apache2/sites-available/my_site):

<Directory /var/www/ucdirc/training>
    AuthType Basic
    AuthName "Protected Information"
    AuthUserFile /etc/apache2/htpassword
    Require valid-user
    Options +Indexes
</Directory>

The +Indexes option shows users the contents of the entire directory when they browse to it. This may or may not be desired.

Next, create a user/passwd pair in the password file with the htpasswd command. Here are some examples for the htpasswd command:

htpasswd /usr/local/etc/apache/.htpasswd-users jsmith

Adds or modifies the password for user jsmith. The user is prompted for the password.

htpasswd -c /home/doe/public_html/.htpasswd jane

Creates a new file and stores a record in it for user jane. The user is prompted for the password.

htpasswd -mb /usr/web/.htpasswd-all jones Pwd4Steve

Encrypts the password from the command line (Pwd4Steve) using the MD5 algorithm, and stores it in the specified file.

More on the htpasswd command: http://httpd.apache.org/docs/2.2/programs/htpasswd.html