Setting Up OpenLiteSpeed with PHP 7.3 and MariaDB 10.4 on CentOS 7
Overview
In this comprehensive tutorial, we will guide you through the process of installing OpenLiteSpeed from LiteSpeed Repositories, coupled with PHP 7.3 and optionally MariaDB 10.4 on a pristine CentOS 7 server. Every step will be thoroughly explained, providing insight into each command’s functionality, empowering you to build your own finely tuned web server with integrated database capabilities.
Requirements
OpenLiteSpeed
OpenLiteSpeed stands as the Open Source iteration of LiteSpeed Web Server Enterprise, renowned for its exceptional performance while maintaining a lightweight footprint. Developed by LiteSpeed Technologies, this web server application offers an optimized alternative to the traditional LAMP Stack.
It features a built-in admin GUI, seamlessly integrating speed, security, scalability, optimization, and simplicity into an open-source solution. OpenLiteSpeed supports multiple operating systems, including Linux, SunOS, Mac OS, and FreeBSD.
PHP
PHP, which recursively stands for PHP: Hypertext Preprocessor, is an extensively utilized open-source scripting language. Recognized for its versatility, PHP is particularly well-suited for web development and can be seamlessly embedded into HTML. In this tutorial, we will explore the capabilities of PHP 7.3, the latest version, to enhance your web development projects.
MariaDB
MariaDB Server, an open-source database crafted by the original MySQL developers, is a trusted choice for global users like Wikipedia and WordPress.com. In this guide, we’ll explore the installation and configuration of MariaDB 10.4, offering a potent database solution for your web applications.
Prerequisites
- A pristine CentOS 7 server instance.
- A non-root user with sudo privileges on the server.
Step 1: Update Your Server and Initial Configuration
sudo yum -y update && sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
Execute the following commands to update your server to the latest stable version, install the REMI Repository, and Yum-Utils to manage yum repositories.
Step2: Set up OpenLiteSpeed
rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
sudo yum -y install openlitespeed
These commands add the OpenLiteSpeed repository to your system and then install the OpenLiteSpeed web server.
Step 3: Installing PHP 7.3 as an RPM
When using OpenLiteSpeed, it’s quicker to install PHP with LiteSpeed SAPI from a repository than to compile it manually. After adding the LiteSpeed repository, leverage yum to install your preferred PHP version for LiteSpeed, including various modules. PHP packages on the LiteSpeed Repository are named ‘lsphp’ followed by the version number.
sudo yum -y install lsphp73 lsphp73-common lsphp73-mysqlnd lsphp73-gd lsphp73-process lsphp73-mbstring lsphp73-xml lsphp73-mcrypt lsphp73-pdo lsphp73-imap lsphp73-soap lsphp73-bcmath lsphp73-intl lsphp73-zip
ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp
The provided commands will install LSPHP 7.3 for OpenLiteSpeed from the OLS repository, including commonly-used packages. These commands also instruct OpenLiteSpeed to utilize this specific PHP version.
LiteSpeed Repository offers PHP versions: PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, and 7.3.
Note: The PHP version will be confirmed in step 5 on the phpinfo() page. You can use the “yum search lsphp73” command to discover the available modules for your version.
Step 4: Configuring Firewall and Ports
sudo firewall-cmd --zone=public --permanent --add-port=8088/tcp
sudo firewall-cmd --zone=public --permanent --add-port=7080/tcp
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
The provided commands will activate the default ports for OpenLiteSpeed, including 8088 and 7080, along with the standard HTTP (80) and HTTPS (443) ports. The firewall rules are then reloaded to apply the changes.
Step 5: Exploring OpenLiteSpeed Server
Launching OpenLiteSpeed Server
/usr/local/lsws/bin/lswsctrl start Configuring Admin Credentials for OpenLiteSpeed WebAdmin GUI
To access the user-friendly WebAdmin UI of OpenLiteSpeed, it’s necessary to configure the admin user credentials. Follow these steps to set up the credentials for accessing the WebAdmin GUI.
sudo /usr/local/lsws/admin/misc/admpass.sh
Give details as listed below:
User name [admin]:
Password:
Retype password: Exploring OpenLiteSpeed Further
Accessing Your OpenLiteSpeed Site:
To access your OpenLiteSpeed site, follow these steps:
Browse to http://[address]:8088/, where [address] is the IP address or domain name of your server.
If the installation is successful, you will see the Congratulations page, indicating that you have successfully installed the OpenLiteSpeed Web Server.
Ignore any SSL security warnings and use the admin credentials you set earlier to sign in.
OpenLiteSpeed Default Directory:
The default directory for OpenLiteSpeed is /usr/local/lsws.
Control Commands:
- Stop OpenLiteSpeed:
/usr/local/lsws/bin/lswsctrl stop - Gracefully restart OpenLiteSpeed (zero downtime):
/usr/local/lsws/bin/lswsctrl restart - Show OpenLiteSpeed commands:
/usr/local/lsws/bin/lswsctrl help - Reset the WebAdmin password from the command line:
/usr/local/lsws/admin/misc/admpass.sh - Switch between XML and plain text configuration files:
/usr/local/lsws/conf/switch_config.sh - Check OpenLiteSpeed version:
/usr/local/lsws/bin/lshttpd -v
Accessing PHP-Info and WebAdmin Console:
Access PHP-Info: Browse to http://[address]/phpinfo.php
Check PHP installation: Verify your PHP installation correctness by viewing a phpinfo() page. It should display the correct PHP and LiteSpeed versions.
Access WebAdmin console: Browse to https://[address]:7080/
Important Notes:
- The default administrator username and password are “admin” and “123456.” Be cautious when entering http and https addresses, as a mistake may lead to connectivity issues.
Step 6: Installing MariaDB for Database Management
Create a Custom Repository File for MariaDB
cat </etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
The provided commands will generate a custom yum repository file named “MariaDB.repo” in the “/etc/yum.repos.d/” folder. This repository file is necessary for installing the latest MariaDB version 10.4.
Install, Run, and Set MariaDB to Auto-Start
sudo yum -y install MariaDB-server MariaDB-client
sudo systemctl enable mariadb
sudo systemctl start mariadb
The given commands will install MariaDB, set it to start automatically on boot, and initiate the service.
Secure MariaDB Installation
Finally, we need to secure our database installation by running the following command. You will be prompted to answer a few questions.
sudo /usr/bin/mysql_secure_installation
You will be presented with the following questions.
Confirm Successful MariaDB Installation
sudo systemctl status mariadb
mysqladmin -u root -p version
Congratulations on completing this tutorial! You have successfully set up an optimized database-web server using the latest technologies.
Copy and Run All Commands
You can easily set up your OpenLiteSpeed server on a clean CentOS 7 instance by copying and running the following commands. In just a few minutes, your server will be ready to function.
sudo yum -y update && sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils
rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
sudo yum -y install openlitespeed
sudo yum -y install lsphp73 lsphp73-common lsphp73-mysqlnd lsphp73-gd lsphp73-process lsphp73-mbstring lsphp73-xml lsphp73-mcrypt lsphp73-pdo lsphp73-imap lsphp73-soap lsphp73-bcmath lsphp73-intl lsphp73-zip
ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp
sudo firewall-cmd --zone=public --add-port=8088/tcp --permanent
sudo firewall-cmd --zone=public --add-port=7080/tcp --permanent
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
/usr/local/lsws/bin/lswsctrl start
cat </etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
sudo yum -y install MariaDB-server MariaDB-client
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo /usr/bin/mysql_secure_installation
