Good idea is to make a dedicated Virtual Host (who will run separate subdomain) for each MediaWiki on your server. Apache2 virtualhost.conf files are contained in the folder /etc/apache2/sites-available/.
For example, the VH configuration file could be named as follow (note its name must end with .conf): /etc/apache2/sites-available/wiki.example.com.conf. And its sample content should be something like:
<VirtualHost *:80>
ServerName wiki.example.com
ServerAdmin [email protected]
# Redirect Requests to SSL
Redirect permanent "/" "https://wiki.example.com/"
ErrorLog ${APACHE_LOG_DIR}/wiki.example.com.error.log
CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName wiki.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/wiki.example.com
# According MWiki Manual:Security
php_flag register_globals off
ErrorLog ${APACHE_LOG_DIR}/wiki.example.com.error.log
CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/wiki.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/wiki.example.com.key
SSLCertificateChainFile /etc/ssl/certs/wiki.example.com.root-bundle.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory /var/www/wiki.example.com>
Options None FollowSymLinks
#Allow .htaccess
AllowOverride All
Require all granted
<IfModule security2_module>
SecRuleEngine Off
# or disable only problematic rules
</IfModule>
</Directory>
# According to MWiki Manual:Security
<Directory /var/www/wiki.example.com/images>
# Ignore .htaccess files
AllowOverride None
# Serve HTML as plaintext, don't execute SHTML
AddType text/plain .html .htm .shtml .php .phtml .php5
# Don't run arbitrary PHP code.
php_admin_flag engine off
# If you've other scripting languages, disable them too.
</Directory>
#According to MWiki Manual:Security
<Directory /var/www/wiki.example.com/images/deleted>
Deny from all
AllowOverride AuthConfig Limit
Require local
</Directory>
</VirtualHost>
</IfModule>
Note that, this example is for configuration with enabled HTTPS/SSL. For pure HTTP it must look like:
<VirtualHost *:80>
ServerName wiki.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/wiki.example.com
# According MWiki Manual:Security
php_flag register_globals off
ErrorLog ${APACHE_LOG_DIR}/wiki.example.com.error.log
CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory /var/www/wiki.example.com>
Options None FollowSymLinks
#Allow .htaccess
AllowOverride All
Require all granted
<IfModule security2_module>
SecRuleEngine Off
# or disable only problematic rules
</IfModule>
</Directory>
# According to MWiki Manual:Security
<Directory /var/www/wiki.example.com/images>
# Ignore .htaccess files
AllowOverride None
# Serve HTML as plaintext, don't execute SHTML
AddType text/plain .html .htm .shtml .php .phtml .php5
# Don't run arbitrary PHP code.
php_admin_flag engine off
# If you've other scripting languages, disable them too.
</Directory>
#According to MWiki Manual:Security
<Directory /var/www/wiki.example.com/images/deleted>
Deny from all
AllowOverride AuthConfig Limit
Require local
</Directory>
</VirtualHost>
Good idea is to make a dedicated Virtual Host (who will run separate subdomain) for each MediaWiki on your server. Apache2 virtualhost.conf files are contained in the folder
/etc/apache2/sites-available/
.For example, the VH configuration file could be named as follow (note its name must end with
.conf
):/etc/apache2/sites-available/wiki.example.com.conf
. And its sample content should be something like:Note that, this example is for configuration with enabled HTTPS/SSL. For pure HTTP it must look like:
To activate the VirtyalHost you need to run:
Read also: