sudo a2disconf mediawiki
sudo systemctl restart php8.5-fpm
nano /etc/apache2/conf-available/mediawiki.conf
代碼: 選擇全部
# Map the /w URL path to the /var/www/html/w directory [Short URLs]
Alias /w /var/www/html/w
<Directory /var/www/html/w>
Options FollowSymLinks
AllowOverride All
Require all granted
# Forward PHP requests inside /w to PHP 8.5-FPM
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.5-fpm.sock|fcgi://localhost"
</FilesMatch>
</Directory>
<Directory /var/lib/mediawiki>
Options FollowSymLinks
AllowOverride All
Require all granted
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.5-fpm.sock|fcgi://localhost"
</FilesMatch>
</Directory>
# --- SECURITY HARDENING: Prevent arbitrary PHP execution in uploads ---
# Block PHP in your main MediaWiki upload folder
<Directory /var/lib/mediawiki/images>
# Turn off the proxy handler for PHP files inside this directory
<FilesMatch \.php$>
SetHandler none
Require all denied
</FilesMatch>
# Override mod_php if it ever accidentally gets turned on globally
<IfModule mod_php.c>
php_admin_flag engine off
</IfModule>
</Directory>
# Short URL Rewriting Engine
# RewriteEngine On
# RewriteRule ^/wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]
# RewriteRule ^/wiki$ /w/index.php [PT,L,QSA]
sudo systemctl restart php8.5-fpm
systemctl restart apache2