Installing OpenLiteSpeed with PHP 7 on CentOS 7
OpenLiteSpeed, the free version of LiteSpeed, is a lightweight and high-performance web server solution.
This guide walks you through the process of setting up OpenLiteSpeed along with PHP 7 on a CentOS 7 machine.
Requirements
- CentOS 7 x64 operating system
- A user with sudo privileges
Step 1: System Update
Access the server using a sudo-enabled account and initiate a system update with the commands below:
sudo yum install epel-release -y
sudo yum clean all && sudo yum update -y && sudo shutdown -r now
Once the system has restarted, log back in using the same sudo-enabled account.
Step 2: Setting Up OpenLiteSpeed
To get OpenLiteSpeed version 1.4.24 installed on your CentOS 7 system, run the following YUM commands:
sudo rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
sudo yum install openlitespeed -y
Step 3: Installing PHP 7
To add PHP support via prebuilt packages specifically for OpenLiteSpeed, you need to install modules prefixed with lsphp
.
Use the following command to see a list of all available packages that start with lsphp
:
yum list lsphp*
To install the frequently used PHP 7.1 components, execute this command:
sudo yum install lsphp71 lsphp71-mysqlnd lsphp71-common lsphp71-gd lsphp71-pdo lsphp71-process lsphp71-mbstring lsphp71-mcrypt lsphp71-opcache lsphp71-bcmath lsphp71-xml -y
Step 4: Set Admin Credentials for the OpenLiteSpeed Web Interface
OpenLiteSpeed provides a convenient graphical interface known as the WebAdmin GUI. Before accessing it, you must set up credentials for the admin account using the following command:
sudo /usr/local/lsws/admin/misc/admpass.sh
When prompted, provide the following input:
- User name [admin]: <your-admin-username>
- Password: <your-admin-password>
- Retype password: <your-admin-password>
Next, enable access to the WebAdmin UI by opening port 7080 on the firewall:
sudo firewall-cmd --zone=public --permanent --add-port=7080/tcp
sudo firewall-cmd --reload
Once configured, launch your browser and navigate to http://203.0.113.1:7080
. You might encounter a security warning regarding SSL—bypass it and log in using the admin credentials you just set.
Step 5: Adjust OpenLiteSpeed to Work with PHP 7.1
By default, version 1.4.24 of OpenLiteSpeed is set to use PHP 5.x. Since this setup uses PHP 7.1, you’ll need to adjust the configurations in the WebAdmin GUI to match.
Start by selecting Server Configuration, then go to the External App tab. Find the external application labeled lsphp5 and click the second icon (Edit) on the right. Modify the settings like this:
- Name: lsphp71
- Address: uds://tmp/lshttpd/lsphp.sock
- Max Connections: 35
- Environment:
PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35 - Initial Request Timeout (secs): 60
- Retry Timeout: 0
- Response Buffering: no
- Auto Start: yes
- Command: $SERVER_ROOT/lsphp71/bin/lsphp
- Back Log: 100
- Instances: 1
- Memory Soft Limit (bytes): 2047M
- Memory Hard Limit (bytes): 2047M
- Process Soft Limit: 400
- Process Hard Limit: 500
Click the Save icon at the top right to apply the changes.
Next, open the Script Handler tab and click the Edit icon to update the handler settings:
- Suffixes: php
- Handler Type: LiteSpeed SAPI
- Handler Name: lsphp71
After updating the values, save your changes by clicking the Save icon again.
Now, go to the Listeners section. Use the View icon to access the Default listener’s configuration. In the General tab of the Default Listener, click Edit and update the following:
- Listener Name: Default
- IP Address: ANY
- Port: 80
Click Save to store your modifications.
Finally, click the Graceful Restart icon in the upper right corner to restart the server and apply all settings.
Step 6: Verify Your Configuration
Start by updating the firewall settings to allow incoming traffic on HTTP port 80:
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
Next, open your web browser and go to http://203.0.113.1
. If the setup was completed correctly, you should see a welcome screen displaying the following message:
You have successfully installed the OpenLiteSpeed Web Server!
To check more technical details about the server and PHP environment, navigate to:
http://203.0.113.1/phpinfo.php
Conclusion
You’ve now completed the setup of OpenLiteSpeed with PHP 7.1 on a CentOS 7 server. From installing essential packages to configuring the WebAdmin interface and fine-tuning the PHP settings, your server is ready to deliver fast and reliable web hosting.
With OpenLiteSpeed’s performance-oriented design and the power of PHP 7.1, your applications can run smoothly and efficiently. You can now explore additional configurations, deploy your websites, or integrate security measures like SSL to further harden your setup.