500 Server Error after moving media wiki directory - php

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.

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/

There is no need to move media wiki from the currently operational location. As you are installing additional applications and media wiki already uses short URL's which makes accessing articles work using the form example.org/wiki/Article_Title what you can do is install the new applications in sub folders right along side the mediawiki installation without any issues at all, as the .htaccess rules will provide exceptions for files and folders which exist on the server.
Example folder structure
public_html /
app1/
index.php
...
app2/
index.php
...
app3/
index.php
...
... (all media wiki files and folders)

I'm not familiar with MediaWiki, but given this comment:
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 found the following comment on mediawiki.org:
If you redefine this [$wgScriptPath] in your LocalSettings.php then all dependent variables will need redefining too!
I'd investigate what else is set during installation time using this value, as that may be the cause of your issue.

Related

URLs not correctly rewritten - mod proxy error

I am running the official docker php image: php:7.4-apache
Some URLs are not correctly being rewritten. We are seeing IPs in some links in the docker container but not when we test locally in MAMP.
These are the types of rewrites we are doing in the htaccess file :
RewriteRule ^gift-cards/(.*)$ http://34.245.51.253/gift-cards/$1 [P]
### Redirect for merchants pages
RewriteRule ^merchants/(.*)$ http://34.245.51.253/merchants/$1 [P]
The logs are showing:
[Mon Nov 14 12:00:14.313116 2022] [proxy:debug] [pid 26] mod_proxy.c(1503): [client 172.17.0.1:56704] AH01143: Running scheme http handler (attempt 0)
[Mon Nov 14 12:00:14.316758 2022] [proxy_ajp:debug] [pid 26] mod_proxy_ajp.c(769): [client 172.17.0.1:56704] AH00894: declining URL http://34.245.51.253/
I can see a similar question here AH00894: declining URL fcgi
But the container isn't running PHP FPM so I am not sure how to proceed?

Php-generated images intermittently showing after moving to HTTPS

I've switched my website to use https, rather than http, and everything is fine apart from images that are generated as a result of Php code executing (static images are ok). As an example, my phpBB forum is one area where this is happening, where images are sporadically not showing (some are, some aren't, with no common pattern). Even simple Php scripts that generate images are showing this strange behavior. If I go back to HTTP then everything is fine.
The error_log contains the following (just one example of an image failing to render), It's almost as if the file generating the image does not complete its execution.
[Mon Dec 30 12:12:01.347282 2019] [core:error]
[pid 247428:tid 23291082008320] [client 90.248.211.216:0] End of script output before headers: file.php, referer: https://www.ukbutterflies.co.uk/phpBB/viewtopic.php?f=37&t=9757
[Mon Dec 30 12:12:01.347709 2019] [:error]
[pid 235457:tid 23291117729536] [client 90.248.211.216:0] SoftException in Application.cpp:630: Could not execute script "/home4/ukbutte1/public_html/phpBB/download/file.php", referer: https://www.ukbutterflies.co.uk/phpBB/viewtopic.php?f=37&t=9757
[Mon Dec 30 12:12:01.348063 2019] [:error]
[pid 235457:tid 23291117729536] [client 90.248.211.216:0] Caused by SystemException in API_Linux.cpp:458: execve() for program "/opt/cpanel/ea-php71/root/usr/bin/php-cgi" failed: Resource temporarily unavailable, referer: https://www.ukbutterflies.co.uk/phpBB/viewtopic.php?f=37&t=9757
The site .htaccess file includes the following, in case this is relevant (this is intended to direct every access request to a secure URL):
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Heroku open and get 502 error with Codeigniter

Just checked my logs and I'm getting this error:
2015-12-21T17:41:06.304648+00:00 app[web.1]: [Mon Dec 21 17:41:06.303907 2015] [autoindex:error] [pid 100:tid 139688442590976] [client 10.147.38.224:15662] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive.
What is going on?
This is likely an issue with you not setting up your Heroku environ properly...have you read through all the documentation? Do you have a Procfile setup in your app root?
Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app.
https://devcenter.heroku.com/articles/getting-started-with-php#define-a-procfile

Does not work routing on prod environment

Does not work routing on prod environment, but on dev all pages load.
Apache log:
[Fri May 17 23:50:05 2013] [error] [client 127.0.0.1] File does not
exist: /mnt/d/web/project/web/front
Browser:
Not Found The requested URL /front was not found on this server.
I changed in virtualHost:
from "AllowOverride none to "AllowOverride All". Now, it work.

PHP page doesn't load. Instead it gives me a 404 error

The title describes the question.
I have PHP installed, Apache, MySQL and also phpMyAdmin in the htdocs folder of Apache. I installed them separately and do not use a compilation package. I did try to create a php file with phpinfo
<?php
phpinfo();
?>
Saved the file as phpinfo.php
When going to
http://localhost
I see the phpinfo.php file listed. When I click the phpinfo.php file
I get a 404 error. There are no other files listed in the root http folder except one (phpinfo.php)
PHP was installed and php short tags are enabled
short_open_tag = On
I am not sure if it's a capital On or on
Note: I used http://www.jesterwebster.com/setting-up-a-test-bench-web-server-with-apache-php-mysql-and-more-on-windows/26 as a guide for my Apache and PHP install
I opened the error log and I found something disturbing. Not sure how to fix it
[Fri Aug 03 13:07:34 2012] [error] [client 127.0.0.1] File does not exist: C:/website/example/online/Program Files, referer: http://localhost/
[Fri Aug 03 13:09:33 2012] [error] [client 127.0.0.1] File does not exist: C:/website/example/online/Program Files, referer: http://localhost/
Per your error logs, your DocumentRoot "C:/websites/example/online" is websiteS, your error log is looking for website without the s.
Have you confirmed from apache configuration file that PHP is enabled and is configured correctly to work with apache? And has the apache server been restarted after configuration? Also Try adding an html file in the htdocs directory to confirm if the directory is correct.
Edit: Also you mentioned that error log is looking for your file in this directory
C:/website/example/online/Program Files
But you mentioned that you placed phpinfo.php in htdocs folder for apache. There might be an issue related to difference between those two paths

Categories