a2enmod modul; untuk menonaktifkan modul, perintahnya adalah a2dismod modul. Program ini benar-benar hanya membuat (atau menghapus) link simbolik di /etc/apache2/mods-enabled/ menunjuk pada file yang sebenarnya (yang disimpan dalam /etc/apache2/mods-available/).
/etc/apache2/ports.conf), dan menyajikan halaman dari direktori /var/www/html/ (seperti yang dikonfigurasi di /etc/apache2/sites-enabled/000-default.conf).
mod_ssl) required for secure HTTP (HTTPS) out of the box. It just needs to be enabled with a2enmod ssl, then the required directives have to be added to the configuration files. A configuration example is provided in /etc/apache2/sites-available/default-ssl.conf.
SSLCertificateFile /etc/letsencrypt/live/DOMAIN/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/DOMAIN/chain.pem SSLCACertificateFile /etc/ssl/certs/ca-certificates.crt
mod_gnutls, which is shipped with the libapache2-mod-gnutls package and enabled with the a2enmod gnutls.
/etc/apache2/sites-enabled/000-default.conf; host virtual ini akan digunakan jika tidak ditemukan host yang cocok dengan permintaan yang dikirim oleh klien.
/etc/apache2/situs-available/. Maka menyiapkan sebuah situs web untuk domain falcot.org adalah cukup dengan sekedar membuat berkas berikut, kemudian memfungsikan host virtual dengan a2ensite www.falcot.org.
Contoh 11.13. Berkas /etc/apache2/sites-available/www.falcot.org.conf
<VirtualHost *:80> ServerName www.falcot.org ServerAlias falcot.org DocumentRoot /srv/www/www.falcot.org </VirtualHost>
CustomLog dalam definisi host virtual). Maka masuk akal untuk menyesuaikan format berkas log ini agar menyertakan nama host virtual. Ini dapat dilakukan dengan menciptakan sebuah berkas /etc/apache2/conf-available/customlog.conf yang menentukan format baru untuk semua berkas log (dengan direktif LogFormat) dan memfungsikannya dengan a2enconf customlog . Baris CustomLog harus juga akan dihapus (atau dijadikan komentar) dari berkas /etc/apache2/sites-available/000-default.conf.
Directory blok; mereka memungkinkan menentukan perilaku yang berbeda untuk server tergantung pada lokasi berkas yang diminta. Blok tersebut umumnya memuat direktif Options dan AllowOverride.
Contoh 11.15. Blok direktori
<Directory /srv/www> Options Includes FollowSymlinks AllowOverride All DirectoryIndex index.php index.html index.htm </Directory>
DirectoryIndex berisi daftar berkas yang akan dicoba ketika permintaan klien cocok dengan suatu direktori. Berkas pertama yang ada dalam daftar digunakan dan dikirim sebagai respon.
Options diikuti oleh daftar pilihan yang diaktifkan. Nilai None menonaktifkan semua pilihan; sejalan dengan itu, All memfungsikan mereka semua kecuali MultiViews. Pilihan yang tersedia meliputi:
ExecCGI indicates that CGI scripts can be executed.
FollowSymlinks tells the server that symbolic links can be followed, and that the response should contain the contents of the target of such links.
SymlinksIfOwnerMatch also tells the server to follow symbolic links, but only when the link and the its target have the same owner.
Includes enables Server Side Includes (SSI for short). These are directives embedded in HTML pages and executed on the fly for each request.
IncludesNOEXEC allows Server Side Includes (SSI) but disables the exec command and limits the include directive to text/markup files.
Indexes tells the server to list the contents of a directory if the HTTP request sent by the client points at a directory without an index file (i.e., when no files mentioned by the DirectoryIndex directive exists in this directory).
MultiViews enables content negotiation; this can be used by the server to return a web page matching the preferred language as configured in the browser.
AllowOverride mencantumkan semua pilihan yang dapat diaktifkan atau dinonaktifkan melalui berkas .htaccess. Penggunaan umum pilihan ini adalah untuk membatasi ExecCGI, sehingga administrator memilih pengguna yang diizinkan untuk menjalankan program di bawah identitas server web (pengguna www-data).
Contoh 11.16. berkas .htaccess yang memerlukan otentikasi
Require valid-user AuthName "Private directory" AuthType Basic AuthUserFile /etc/apache2/authfiles/htpasswd-private
/etc/apache2/authfiles/htpasswd-private file contains a list of users and passwords; it is commonly manipulated with the htpasswd command. For example, the following command is used to add a user or change their password:
#htpasswd /etc/apache2/authfiles/htpasswd-private userNew password: Re-type new password: Adding password for user user
Require directive controls access restrictions for a directory (and its subdirectories, recursively).
Require digabung dalam sebuah blok RequireAll.
/etc/awstats/awstats.conf. Para administrator Falcot mempertahankannya kecuali parameter berikut:
LogFile="/var/log/apache2/access.log" LogFormat = "%virtualname %host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot" SiteDomain="www.falcot.com" HostAliases="falcot.com REGEX[^.*\.falcot\.com$]" DNSLookup=1 LoadPlugin="tooltips"
LogFile dan LogFormat menggambarkan lokasi dan format berkas log dan informasi di dalamnya; SiteDomain dan HostAliases berisi daftar berbagai nama yang dipakai oleh situs web utama.
DNSLookup biasanya tidak diatur ke 1; untuk situs kecil, seperti Falcot yang dijelaskan di atas, pengaturan ini memungkinkan mendapatkan laporan yang lebih mudah dibaca yang meliputi nama-nama lengkap mesin bukan alamat IP mentah.
/etc/awstats/awstats.www.falcot.org.conf.
Contoh 11.18. Berkas konfigurasi AWStats untuk sebuah host virtual
Include "/etc/awstats/awstats.conf" SiteDomain="www.falcot.org" HostAliases="falcot.org"
/usr/share/awstats/ikon/. Agar ikon ini akan tersedia di situs web, konfigurasi Apache perlu disesuaikan untuk menyertakan direktif berikut:
Alias /awstats-icon/ /usr/share/awstats/icon/