Для работы медиа-вики на apache2 необходим файл /etc/apache2/conf/mediawiki
. Где я могу найти это?
Хорошая идея состоит в том, чтобы сделать специализированный Виртуальный Хост (кто выполнит отдельный субдомен) для каждого MediaWiki на Вашем сервере. Файлы Apache2 virtualhost.conf содержатся в папке /etc/apache2/sites-available/
.
, Например, конфигурационный файл СПИДОБАРОГРАФА можно было назвать следующим образом (обратите внимание, что его имя должно закончиться .conf
): /etc/apache2/sites-available/wiki.example.com.conf
. И его демонстрационное содержание должно быть чем-то как:
<VirtualHost *:80>
ServerName wiki.example.com
ServerAdmin admin@wiki.example.com
# 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 admin@wiki.example.com
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>
Примечание, что, этот пример для конфигурации с включенным HTTPS/SSL. Для чистого HTTP это должно быть похожим:
<VirtualHost *:80>
ServerName wiki.example.com
ServerAdmin admin@wiki.example.com
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>
Для активации VirtyalHost необходимо работать:
sudo a2ensite wiki.example.com.conf
sudo systemctl restart apache2.service
Read также: