Apache
Jump to navigation
Jump to search
Enabling .htaccess files
Check that you don't have an overall 'AllowOverride None in Apache's configuration file (/etc/apache2/httpd.conf)
Tags
DirectoryIndex
- Use DirectoryIndex to change list of default name of index file while browsing directory
DirectoryIndex index.php index.html # Will serve php version first
DirectoryIndex mycustomindex.html # To point to specific file when browsing directory (no directory listing)
HTTPS
From [1]. Assumptions:
- Already a website present at /var/www
- Package ssl-cert installed (that create snakeoil (i.e. self-signed) certificates in /etc/ssl)
# Load and enable SSL module
sudo a2enmod ssl
sudo /etc/init.d/apache2 force-reload
# Edit file
sudo vim /etc/apache2/sites-available/default-ssl
# ... and change lines as follows (for key/cert we use the snakeoil ones):
# SSLEngine on
# SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
#Enable the default SSL site:
sudo a2ensite default-ssl
# Tell Apache to reload its configuration:
sudo /etc/init.d/apache2 reload
To also add user authentication, add the following lines to either
- File .htaccess in website directory
- Section <Directory /> in /etc/apache2/sites-available/default-ssl:
AuthType Basic
AuthName "default"
AuthUserFile /var/www/nxl67002ux.ssl.passwd
Require valid-user
Then create the password file with the command htpasswd -c filename.passwd username
Finally, reload apache2:
sudo /etc/init.d/apache2 reload