Building Custom PHP¶
Danger
We do not recommend this method! In most situations, you should install LSPHP through the LiteSpeed repository.
We are providing these instructions as a courtesy, but compiling and building PHP is out of the scope of our web server support. Building PHP is a big topic. If you experience trouble, we will not be able to help you. You may be able to find assistance on a PHP users forum.
If you have a rare situation that requires you to compile and build PHP for some special need, you can use OpenLiteSpeed's Compile PHP tool.
Navigate to WebAdmin console > Tools > Compile PHP. Select a PHP Version and click Next.
Choose build options¶
The Installation Path Prefix designates the location where the PHP executable will be built. (It is equivalent to '--prefix='
in the mod_php build options.) This setting is important because this is where your php.ini
will be and where extensions should be installed. Use the Configure Parameters and Add-on Modules fields to selected necessary compile options and modules. Click Next when you're finished.
Build PHP¶
At this point, the configuration is saved in case you need to make another build. The tool will begin compiling PHP for you. Be sure not to refresh your browser or leave the page, or the process will be interrupted. You can monitor the build progress in the Main Status window.
If you would like to see a more detailed log, you can view the file that is named in the first line of the Main Status window. In the screenshot above, it says:
**MAIN STATUS** retreived from /usr/local/lsws/phpbuild/buildphp_1528800346.4.progress
To see the full details, you would open /usr/local/lsws/phpbuild/buildphp_1528800346.4.progress
from the command line.
Verify¶
Once the build is complete, OpenLiteSpeed automatically copies the PHP executable to $SERVER_ROOT/fcgi-bin?
and creates a new $SERVER_ROOT/fcgi-bin/lsphp7
symlinked to the new PHP executable. This is done because the default PHP external application is set to read from $SERVER_ROOT/fcgi-bin/lsphp7
. By using these symlinks instead of overwriting, our new build is automatically used by the default external applications and we do not have to change the location specified in the External Application settings, but we are still able to quickly revert back to our previous build by changing the symlink if something goes wrong.
To see the new version number for LSPHP v7, you can run the ./lsphp7 -v
command. In the screenshot above, that returns the value of PHP 7.2.5 (litespeed)
.
For further verification, point your browser to your phpinfo page at https://example.com:8088/phpinfo.php
and check all of your configurations.