PHP 500 Error in Plesk

You may encounter random PHP 500 errors on domains with multiple subdomains.

This occurs when open_basedir protection is set to {DOCROOT}{/}{:}{TMP}{/} in Plesk's PHP settings, and multiple subdomains are defined inside a single parent domain, like in this example:

  • /var/www/vhosts/example.com/httpdocs/
  • /var/www/vhosts/example.com/sub1.example.com/
  • /var/www/vhosts/example.com/sub2.example.com/

You may see the 500 error in either the parent domain or one of the subdomains, depending on which domain is accessed first and where lsphp is started. You'll see an entry like this in the debug log:

2019-12-23 17:38:22.972520 [NOTICE] [1659563] [123.123.123.123:51625-1#APVH_example.com:lsapi] [STDERR] PHP Fatal error:  Unknown: Failed opening required '/var/www/vhosts/example.com/sub1.example.com/index.php' (include_path='.:/opt/alt/php73/usr/share/pear') in Unknown on line 0

Here's why: when the lsphp process is started by example.com, it will apply open_basedir as /var/www/vhosts/example.com/httpdocs/, so the subdomain cannot access its files in /var/www/vhosts/example.com/sub1.example.com/.

In Plesk, the {DOCROOT} variable is set to /var/www/vhosts/example.com/httpdocs or /var/www/vhosts/example.com/sub1.example.com/, for a domain and subdomain respectively.

The {WEBSPACEROOT} variable is set to /var/www/vhosts/example.com/, which is valid for all subdomains inside this same account.

There are several ways to solve this issue:

# If you have CageFS, there might not be much extra benefit to using open_basedir, so the simplest solution is to turn it off.
# Change open_basedir from ''{DOCROOT}'' to  ''{WEBSPACEROOT}'', though this will not apply individual open_basedir to each subdomain.
# Edit ''/usr/local/lsws/conf/httpd_config.xml'', insert the line ''<phpAppByDomain>1</phpAppByDomain>'' anywhere between ''<phpConfig>'' and ''</phpConfig>'', as seen in the screenshot below, then restart LSWS, killing lsphp if necessary.

  • Admin
  • Last modified: 2020/01/07 16:33
  • by qtwrk