Change PHP Settings by Vhost and User

You are here:
< Back

By default, OpenLiteSpeed launches lsphp processes with the global php.ini settings, which means your ten virtual hosts running the same PHP version will all be using the same PHP settings. In some cases, you may want to change the PHP settings for one particular vhost while leaving all other vhosts with the default settings intact.


Let’s say you have Memory Limit set to 128M in your global php.ini. The following phpinfo page illustrates this:

If you have one virtual host (call it that needs the limit set to 512M you can set a vhost-level php.ini for that virtual host. Here’s how:

Step 1

Edit the External App in WebAdmin Console, and add the following code to Environment:


(Please remember to change the path to match your vhost’s actual web root.)

Restart OpenLiteSpeed.

Step 2

Create a new php.ini by copying the content of the global php.ini. This is important so that all of the modules are loaded.

cat /usr/local/lsws/lsphp73/etc/php.ini > /home/

Change the Memory Limit to 512M in the new php.ini.

[root@test public_html]# cat php.ini | grep memory_limit
memory_limit = 512M

Step 3

Reload the phpinfo page for the virtual host, and you should see the changed memory limit. If you do not, restart OpenLiteSpeed again to force lsphp to restart.

As you can see, the memory limit has been raised to 512M:


.user.ini can be used on a single directory when it’s necessary to change a particular setting to be different than the vhost-level or global-level setting. We’ll use Memory Limit again in this example.

Edit the External App in WebAdmin Console, and add the following code to Environment:


Like so:

Save it and restart OpenLiteSpeed.

Create a separate subdirectory and a new .user.ini:

[root@test test]# cat .user.ini
memory_limit = 768M

Set Memory Limit to 768M to distinguish it from the previous vhost PHP setting.