Installing MySQL on OpenLiteSpeed Server
Connect to your server via SSH and execute the following command to install MySQL. During installation, you will be prompted to set a password for the root user. Ensure you set a strong password.
apt-get install mysql-server
Note: The original post referenced MySQL 5.5, which is outdated. For new deployments, it is recommended to install a more recent version (e.g., MySQL 8.0 or MariaDB 10.x) for better performance and security updates. You can check available versions with apt-cache search mysql-server.
Compiling and Installing PHP for OpenLiteSpeed
This section guides you through compiling a custom PHP version via the OpenLiteSpeed admin panel.
Step 1: Access the Compilation Interface
Log into the OpenLiteSpeed admin panel (default address is typically https://your-server-ip:7080). In the top navigation bar, find the Actions menu and select Compile PHP.
Step 2: Select PHP Version and Modules
On the compilation page, select your desired PHP version. It is strongly recommended to choose a supported version like PHP 7.4 or PHP 8.x rather than outdated, unsupported versions. Click Next.
In the module selection section, check the modules required for your application. For example, to use XCache as an opcode cache, ensure XCache is selected.
Step 3: Configure Compilation Parameters
You need to provide PHP compilation configuration parameters. Here is a reference example suitable for modern Linux distributions (e.g., Ubuntu 20.04/22.04):
'--with-litespeed' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-openssl' '--with-curl' '--with-zlib' '--with-gd' '--with-jpeg' '--with-freetype' '--enable-mbstring' '--enable-xml' '--enable-sockets' '--enable-bcmath' '--enable-soap' '--enable-pcntl'
Important Notes:
- The
--with-libdirparameter is usually not required; the system detects it automatically. - The SPDY protocol mentioned in older guides has been superseded by HTTP/2 and HTTP/3. OpenLiteSpeed supports HTTP/2 by default; no special PHP parameter is needed.
- The
mcryptmodule is deprecated since PHP 7.2; useopensslinstead.
Step 4: Troubleshooting Common Compilation Errors
If you encounter errors during compilation, refer to these solutions:
- Error:
configure: error: Cannot find OpenSSL's libraries
Solution: Install the OpenSSL development package:apt-get install libssl-dev - Error:
**ERROR** Could not run PHPize for XCache
Solution: Install the PHP development package for your version. For PHP 7.4:apt-get install php7.4-dev
Step 5: Execute Compilation and Finalize
After configuration, OpenLiteSpeed will download the source code and prepare for compilation. Before the final compilation begins, the admin panel will display a command that must be executed in the server's SSH terminal. Copy and run this command on your server to start the actual compilation process.
Warning: Compilation can take a long time. Do not refresh the admin page or close your SSH session during this process. You can monitor progress and logs in the admin panel under Main Status and Detailed Log.
Once compilation is successful, return to the OpenLiteSpeed admin panel. Under the Actions menu, select Graceful Restart to restart the server and activate the newly compiled PHP.
Additional Note: XCache is a PHP opcode cache but has seen less maintenance in recent years. For production environments, it is recommended to use OpenLiteSpeed's built-in LSCache or the widely supported OPcache (included by default when compiling PHP).