Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
litespeed_wiki:php:per-user-php-ini [2017/11/13 21:26] Johathan Kagan [Notes] |
litespeed_wiki:php:per-user-php-ini [2018/11/13 22:44] Jackson Zhang |
||
---|---|---|---|
Line 104: | Line 104: | ||
This directive is supported since PHP LSAPI version V6.10. | This directive is supported since PHP LSAPI version V6.10. | ||
+ | |||
+ | ===== 7. Special Apache directive LS_EXTAPP_ENV on cpanel to override External application environment variables ===== | ||
+ | |||
+ | On CPanel or other control panel environment, you may have set up "PHP_INI_SCAN_DIR" as step 3 and also set up "PHP_INI_SCAN_DIR" as step 1. LSWS will use "PHP_INI_SCAN_DIR" from external app environment instead of Apache directives. Is there any way to override the external app environment? Starting from LSWS 5.3.4, a new special apache directive "LS_EXTAPP_ENV" has been introduced for this purpose. You can place it in Apache virtual host include file to override external app environment settings. | ||
+ | |||
+ | For example, you have set the following in external app environment: | ||
+ | PHP_INI_SCAN_DIR=/home/USER1/public_html | ||
+ | but if you want to override it to another location as "/home/USER1/data", you can add the following to Apache virtual host include file: | ||
+ | <IfModule Litespeed> | ||
+ | LS_EXTAPP_ENV PHP_INI_SCAN_DIR=/home/USER1/data/ | ||
+ | </IfModule> | ||
===== Notes ===== | ===== Notes ===== | ||
* **PHP suEXEC MUST BE ENABLED IN LSWS.** | * **PHP suEXEC MUST BE ENABLED IN LSWS.** | ||
- | * Make sure the php.ini file is readable by the suEXEC user. | + | * Make sure the php.ini file is readable by the **Run As User** user. |
* Option 3 can be used along with options 1, 2, or 4 without conflicts. However, this should rarely be needed. | * Option 3 can be used along with options 1, 2, or 4 without conflicts. However, this should rarely be needed. | ||
* Option 4 takes precedence over options 1 and 2 should they be used at the same time. | * Option 4 takes precedence over options 1 and 2 should they be used at the same time. | ||
* Changes in the php.ini will not be picked up until new PHP process starts. The php.ini is read for the first time when a PHP process starts. | * Changes in the php.ini will not be picked up until new PHP process starts. The php.ini is read for the first time when a PHP process starts. | ||
- | * Per-user php.ini files are not compatible with [[http://www.litespeedtech.com/products/litespeed-sapi/php/suexec-daemon-mode|suEXEC Daemon mode]]. Our [[http://www.litespeedtech.com/products/litespeed-sapi/php/guide-to-suexec-setups|two other PHP suEXEC setups]] both support per-user php.ini. | + | * Per-user php.ini files are not compatible with [[http://www.litespeedtech.com/products/litespeed-sapi/php/suexec-daemon-mode|Daemon mode]]. Our [[http://www.litespeedtech.com/products/litespeed-sapi/php/guide-to-suexec-setups|two other PHP process modes]] both support per-user php.ini. |
* For native LSWS installs, these variables ($VH_ROOT, $VH_NAME, $VH_USER, etc.) need to be inside of a Virtual Host External App Environment Section, and not inside the general Server External App Environment Section. This is because the variables are expanded on start up, so the VH_* variables cannot be expanded during server level configurations. | * For native LSWS installs, these variables ($VH_ROOT, $VH_NAME, $VH_USER, etc.) need to be inside of a Virtual Host External App Environment Section, and not inside the general Server External App Environment Section. This is because the variables are expanded on start up, so the VH_* variables cannot be expanded during server level configurations. | ||
+ | |||
+ | |||
+ | ===== Troubleshoot ===== | ||
+ | Some PHP extensions are missing after being loaded with per user ''php.ini'', for example | ||
+ | <code>Your PHP installation appears to be missing the MySQL extension which is required by WordPress.</code> | ||
+ | |||
+ | This is because once custom php.ini is loaded, the default php.ini will be ignored. Therefore, extensions will not be loaded. | ||
+ | |||
+ | The easiest way to resolve this problem is to copy the contents of the default php.ini into the custom php.ini by the following command: | ||
+ | |||
+ | <code>cat /opt/cpanel/ea-phpXX/root/etc/php.ini /opt/cpanel/ea-phpXX/root/etc/php.d/*.ini > /path/to/php.ini</code> | ||
+ | |||
+ | Please replace ''ea-phpXX'' and ''/path/to/php.ini'' with the appropriate version and path. | ||
+ | |||
+ | Verify the php.ini content and restart LSWS if necessary, as a change in php.ini will not take effect until a new PHP process starts. The php.ini is read for the first time when a PHP process starts. |