Specify a Specific PHP Runtime Environment for Services
In ServBay, specifying a particular PHP runtime environment for a PHP script or website is very simple. This article will detail how to specify a specific PHP version for PHP scripts and websites.
Specify a Specific PHP Version for PHP Scripts
In ServBay, you can easily specify the PHP version used for a PHP script via the command line. Just use the php-<version>
command. For example, to run a script using PHP 5.6, you can execute the following commands:
$ php-5.6 version.php
Hello World
PHP Version: 5.6.40
$ php-7.3 version.php
Hello World
PHP Version: 7.3.33
2
3
4
5
6
7
Explanation of the Example
php-5.6 version.php
: Runs theversion.php
script using PHP 5.6.php-7.3 version.php
: Runs theversion.php
script using PHP 7.3.
In this way, you can flexibly test and run the compatibility of different PHP versions.
Specify a Specific PHP Version for Websites
If you need to specify the PHP runtime version for an entire website, you can do so through the ServBay management interface.
Steps
Open ServBay Management Interface: Open the ServBay management interface and log into the management console.
Navigate to Host Settings: Click
Host
in the navigation menu.Select the Specific Website: Find the specific website needing the settings in the website list, and click on the settings drop-down menu on the right.
Choose PHP Version: In the settings drop-down menu, select the desired PHP version. Ensure that the corresponding PHP version service is installed and running.
Precautions
- Ensure PHP Version is Installed: Before selecting the PHP version, ensure that version of PHP is installed and running in ServBay.
- Compatibility Check: After switching the PHP version, it is recommended to check the website's compatibility to ensure all functions work correctly.
Summary
Specifying a specific PHP runtime environment in ServBay is very simple. You can specify the runtime version of PHP scripts directly via the command line, or specify the PHP version for an entire website through the ServBay management interface. Whether it's a single script or an entire website, you can flexibly switch PHP versions to meet different development and operational needs.