Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 Server Error after moving media wiki directory

I had a media wiki installation on the main directory /public_html/ of my domain and had short URLs enabled to http://example.org/wiki/Page_title so I had an .htaccess file with the following rules

# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]

I want to install other applications in the main directory of that domain so I am trying to move this media wiki installation from the root /public_html/ directory to the /public_html/w/ while keeping the same short url format. So all I did was copy the content from the main directory to the /public_html/w/ directory and modify the .htaccess rules to

## http://www.mediawiki.org/wiki/Manual:Short_URL/Apache

# Enable the rewrite engine
RewriteEngine On

# Short url for wiki pages
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

And also modify the LocalSettings.php file in the new directory from

$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

to

$wgScriptPath = "/w";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

In theory, since it's using the same db and all the same settings all I needed to change was the htaccess and localsettings.php directories and it should work fine but after I tried it I got a 500 server error and the site was not working at all and after I checked apache/php error logs I found a lot of the same stuff

[Sun Feb 28 13:59:14.477785 2016] [:error] [pid 12164] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:21.854117 2016] [:error] [pid 12165] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:32.073190 2016] [:error] [pid 12374] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:33.574025 2016] [:error] [pid 12166] [client SERVER IP] script '/home/admin/web/MY DOMAIN/public_html/index.php' not found or unable to stat
[Sun Feb 28 13:59:35.873162 2016] [:error] [pid 12167] [client SERVER IP] PHP Warning:  require_once(/home/admin/web/MY DOMAIN/public_html/w/extensions/MsUpload/msupload.php): failed to open stream: No such file or directory in /home/admin/web/MY DOMAIN/public_html/w/LocalSettings.php on line 301
[Sun Feb 28 13:59:35.873207 2016] [:error] [pid 12167] [client SERVER IP] PHP Fatal error:  require_once(): Failed opening required '/home/admin/web/MY DOMAIN/public_html/w/extensions/MsUpload/msupload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/admin/web/MY DOMAIN/public_html/w/LocalSettings.php on line 301

Notice the first errors are still referring to the previous root /public_html/ directory while the extensions errors are already referring to the /public_html/w/ directory

I have no clue where I went wrong here so I would appreciate some help. So far I had to revert the changes and restore a backup I had for the old directory but I still want to move the wiki directory.

like image 629
spacing Avatar asked Feb 28 '16 14:02

spacing


Video Answer


1 Answers

If you are still keeping /home/admin/web/MY DOMAIN/public_html/ as the root directory (as identified from the webserver) but, moving Mediawiki down a level, you might need to change the following:

RewriteBase /w/
like image 183
Simon Avatar answered Sep 25 '22 00:09

Simon