Specifying a Specific Version of the PHP Runtime Environment for Services
In ServBay, specifying a specific version of the PHP runtime environment for a project, a PHP script, or a website is very simple. This article will detail how to specify a particular PHP version for PHP scripts and websites.
Specifying a Specific Version of PHP for a Project
ServBay supports project-level PHP runtime environment settings, which are implemented through the .servbay.config
file. For detailed settings and usage methods, please refer to the article Using the .servbay.config File.
Specifying a Specific Version of PHP for PHP Scripts
If you do not want to specify the PHP version at the project level and only want to temporarily call a specific version of PHP, you can use this method.
In ServBay, you can easily specify the PHP version used by a PHP script through the command line. Just use the php-<version>
command. For example, to run a script with PHP 5.6, you can execute the following command:
$ 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 Example
php-5.6 version.php
: Run theversion.php
script using PHP version 5.6.php-7.3 version.php
: Run theversion.php
script using PHP version 7.3.
This method allows you to flexibly test and run compatibility with different PHP versions.
Specifying a Specific Version of PHP for a Website
If you need to specify the PHP runtime version for an entire website, you can set it through the ServBay management interface.
Steps
Open the ServBay Management Interface: Open ServBay in the application.
Navigate to Website Settings: Click on
Website
in the left navigation menu.Select the Specific Website: Find the specific website you want to set in the website list, and click on the
PHP Version
dropdown menu on the right.Select PHP Version: In the PHP version dropdown menu, select the PHP version you want to use. Make sure the corresponding PHP version service is installed and running. Click save.
Notes
- Ensure PHP Version is Installed: Before selecting a PHP version, please ensure that the version of PHP is installed and running in ServBay.
- Compatibility Check: After switching PHP versions, it is recommended to check the website's compatibility to ensure all functions are operating correctly.
Summary
In ServBay, specifying a specific version of the PHP runtime environment is very simple. You can specify a project-level PHP runtime version through the .servbay.config
file, directly specify the runtime version of PHP scripts via the command line, or set the PHP version for an entire website through the ServBay management interface. Whether for a project, a single script, or an entire website, you can flexibly switch PHP versions to meet different development and runtime needs.