Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
litespeed_wiki:plesk:php_500_error [2019/12/24 12:28] qtwrk created |
litespeed_wiki:plesk:php_500_error [2022/08/30 22:29] (current) qtwrk |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | When in Plesk PHP setting , | + | ====== PHP 500 Error in Plesk ====== |
+ | You may encounter random PHP 500 errors on domains with multiple subdomains. | ||
- | open_basedir protection is set to ''{DOCROOT}{/}{:}{TMP}{/}'' | + | 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: |
- | and multiple sub-domain inside one same parent domain, e.g | + | * ''/var/www/vhosts/example.com/httpdocs/'' |
+ | * ''/var/www/vhosts/example.com/sub1.example.com/'' | ||
+ | * ''/var/www/vhosts/example.com/sub2.example.com/'' | ||
- | ''/var/www/vhosts/example.com/httpdocs/'' | + | 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: |
- | + | ||
- | ''/var/www/vhosts/sub1.example.com/httpdocs/'' | + | |
- | + | ||
- | ''/var/www/vhosts/sub2.example.com/httpdocs/'' | + | |
- | + | ||
- | Then you may encounter randomly PHP 500 error in sub site or vice verse depends on which domain is accessed first and started lsphp, and in debug log you will see entries like this: | + | |
<code> | <code> | ||
Line 17: | Line 14: | ||
</code> | </code> | ||
- | The reason for that error is when the lsphp process is started by example.com , it will apply open_basedir by ''/var/www/vhosts/example.com/httpdocs/'' so the sub site can not access to its files in ''/var/www/vhosts/example.com/sub1.example.com/'' | + | 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 , variable ''{DOCROOT}'' will treated as ''/var/www/vhosts/example.com/httpdocs'' or ''/var/www/vhosts/example.com/sub1.example.com/'' respectively. | + | |
- | and variable ''{WEBSPACEROOT'' will be treated as ''/var/www/vhosts/example.com/'' which includes for all subdomains inside this same account. | + | 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. |
- | ==== Solutions: ==== | + | The ''{WEBSPACEROOT}'' variable is set to ''/var/www/vhosts/example.com/'', which is valid for all subdomains inside this same account. |
- | There are several solutions to this issue: | + | ===== Solutions: ===== |
- | 1. If you have CageFS, there might not be much extra benefit by using open_basedir , so the simplest solution is to turn it off. | + | There are several ways to solve this issue: |
- | 2. Change open_basedir from ''{DOCROOT}'' to ''{WEBSPACEROOT}'' though this will not apply individual open_basedir to each sub domains. | + | * If you have CageFS, there might not be much extra benefit to using open_basedir, so the simplest solution is to turn it off. |
- | 3. Edit ''/usr/local/lsws/conf/httpd_config.xml'' , insert line ''<phpAppByDomain>1</phpAppByDomain>'' anywhere between ''<phpConfig>'' and ''</phpConfig>'' , as screenshot, then restart LSWS and kill lsphp if necessary. | + | * 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. | ||
{{:litespeed_wiki:plesk:screenshot2019-12-2413.26.05.png|}} | {{:litespeed_wiki:plesk:screenshot2019-12-2413.26.05.png|}} | ||