LSPHP directive for php.ini on shared servers

ByJUJU-dev

LSPHP directive for php.ini on shared servers

The LSPHP directive is a powerful tool for managing PHP versions on shared servers. Here’s what you need to know:

What is LSPHP?

LSPHP (Linux Shared PHP) is a module that allows you to manage multiple PHP versions on a single server, giving you more flexibility and control over your PHP configurations.

How does LSPHP work?

LSPHP creates a separate PHP-FPM (FastCGI Process Manager) instance for each PHP version, allowing you to run multiple PHP versions simultaneously. This enables you to switch between different PHP versions for different domains or subdomains.

Configuring LSPHP

To configure LSPHP, you’ll need to edit the php.ini file and add the following directives:

[lsphp]
; Set the PHP version
php_version = 7.4

; Set the document root for this PHP version
document_root = /path/to/document/root

; Set the socket file for this PHP-FPM instance
listen = /path/to/socket/file

; Set the user and group for this PHP-FPM instance
user = username
group = groupname

Replace php_version with the desired PHP version (e.g., 7.4, 7.3, or 5.6), and document_root with the path to your website’s document root.

Enabling LSPHP

To enable LSPHP, add the following line to your httpd.conf file (or apache2.conf on Ubuntu-based systems):

Include /path/to/lsphp.conf

Restart Apache

After making changes to the configuration files, restart Apache to apply the changes:

sudo service apache2 restart

Switching between PHP versions

To switch between PHP versions, simply update the php_version directive in your php.ini file and restart Apache.

For example, if you want to switch from PHP 7.4 to PHP 7.3:

[lsphp]
php_version = 7.3

Then, restart Apache:

sudo service apache2 restart

Tips and considerations

  • Make sure to update the php.ini file for each domain or subdomain that requires a specific PHP version.
  • You can have multiple LSPHP instances running on the same server, allowing you to run different PHP versions for different domains or subdomains.
  • Be cautious when updating the php.ini file, as it can affect all domains or subdomains using that PHP version.
  • If you’re not familiar with LSPHP configuration, consider consulting your hosting provider’s documentation or seeking assistance from their support team.

By mastering LSPHP, you can gain more control over your PHP configurations and take advantage of the latest features and security patches.

About the author

JUJU-dev administrator

Leave a Reply

15 − 1 =