How to Install OpenLiteSpeed with PHP 7.3 and MariaDB 10.4 on CentOS 7

Introduction

In this tutorial, we will learn how to install OpenLiteSpeed from LiteSpeed Repositories along with PHP 7.3 and MariaDB10.4 (optionally) on a clean CentOS 7 server explaining step-by-step all the commands and what they do so you can ultimately create your own optimized web server with database capabilities.

Technologies which will be used.

OpenLiteSpeed

OpenLiteSpeed is the Open Source edition of LiteSpeed Web Server Enterprise with high performance but yet a light-weight web server application developed by LiteSpeed Technologies. Think of it as an optimized version of the regular LAMP Stack packed with a built-in admin GUI combining speed, security, scalability, optimization, and simplicity in one friendly open-source package supporting various operating systems, including Linux, SunOS, Mac OS, and FreeBSD.

PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. In this Tutorial, we will use the PHP7.3 version.

MariaDB

MariaDB Server is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source. Notable users include Wikipedia, WordPress.com, and Google.

Prerequisites

 

  • A clean CentOS 7 server instance.
  • A non-root user with sudo privileges on the server.

Step 1: Update your Server & Initial Steps

sudo yum -y update && sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum-utils

These commands will update your server to the latest stable version and will install REMI Repository and Yum-Utils to manage yum repositories.

Step 2: Install OpenLiteSpeed

rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm
sudo yum -y install openlitespeed

These commands will add the OpenLiteSpeed repository and then Install OpenLiteSpeed.

Step 3: Installing PHP 7.3 as an RPM.

For OpenLiteSpeed, Installing PHP with LiteSpeed SAPI from a repository is much faster than compiling it yourself.
Once LiteSpeed repository is added, you can use yum to install your desired PHP version for LiteSpeed along with a variety of modules.
PHP packages on LiteSpeed Repository name start with '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 above commands will install LSPHP 7.3 for OpenLiteSpeed from OLS repository with all the commonly-used packages and direct OpenLiteSpeed to use this PHP.

LiteSpeed Repository PHP versions: 
PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2 and 7.3

Notes
We will confirm later our PHP version on the phpinfo() page at step 5.
You can use the command "yum search lsphp73" to find the list with all the available modules for your version.

Step 4: Configure Firewall & 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 above commands will enable the default ports of OpenLiteSpeed 8088 and 7080 together with HTTP(80) & HTTPS(443) ports. Lastly, we are reloading our firewall rules.

Step 5: Getting around OpenLiteSpeed server

5-A) Starting OpenLiteSpeed server

/usr/local/lsws/bin/lswsctrl start

5-B) Setup admin credentials for OpenLiteSpeed WebAdmin GUI

OpenLiteSpeed comes with a user-friendly WebAdmin UI. Before you can use the UI, you need to setup the admin user credentials as follows:

sudo /usr/local/lsws/admin/misc/admpass.sh

Provide info as below

User name [admin]: <your-admin-username>
Password: <your-admin-password>
Retype password: <your-admin-password>

5-C) Learning more about OpenLiteSpeed

Access your site:

 

  • Browse to http://[address]:8088/ [address] being the IP address or domain name of your server.

If everything goes well, you will see the Congratulations page which announces that 
You have successfully installed the OpenLiteSpeed Web Server!

Note
Ignore the SSL security warning, and then use the admin credentials you set earlier to sign in.

OpenLiteSpeed Default Directory

/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

Access to OpenLiteSpeed PHP-Info 
* Browse to http://[address]/phpinfo.php

Check your PHP installation 
You can check that your PHP installation is correct by viewing a phpinfo() page. The phpinfo() page should show the correct version of PHP and LiteSpeed as the server API.

Access your WebAdmin console: 
* Browse to https://[address]:7080/

Notes
The defaults for the administrator’s user name and password are “admin” and “123456”.
Be careful with http and https when you are trying to access your web server because it won't work if you type it wrong.

Step 6: Install MariaDB

6-A) Create MariaDB custom repository file

cat <<EOF >/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 above commands will create the custom yum repository file under folder "/etc/yum.repos.d/" with the name "MariaDB.repo" that is required to install the latest MariaDB version 10.4.

6-B) Install, Run & AutoBoot MariaDB

sudo yum -y install MariaDB-server MariaDB-client
sudo systemctl enable mariadb
sudo systemctl start mariadb

The above commands will install MariaDB and enable it to start on boot and then it will run the service.

6-C) Secure Installation

Lastly, we need to secure our database installation through the following command. You will be required to answer a couple of questions.

sudo /usr/bin/mysql_secure_installation

You will be prompted with the following questions.

6-D) Confirm Successful installation

sudo systemctl status mariadb
mysqladmin -u root -p version

The above commands will display the status of the MariaDB service along with the version.

Congratulations on completing this tutorial, you have now ready an optimized db-web server using the latest technologies!


All Commands Copy & Run

You can simply copy the following commands, run them to your clean centos7 server and your OpenLiteSpeed server will be ready in a few minutes 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 <<EOF >/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

 

  • openlitespeed, webserver, mariadb, centos7, php, database server
  • 58 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

Setup Your Own Private VPN with PPTP

PPTP VPN IntroductionTired of being geo blocked and not being able to watch your favorite TV...

Protect DirectAdmin from Brute Force Attacks

A common method of gaining access over a server is to use a technique called a brute force...

Changing Your Server's Time Zone

Changing the time zone that your server is set to is relatively simple and straight forward. In...

Synchronizing Your Server's Clock

Synchronizing your server's clock is not very difficult as there is a program that can be ran by...

Installing CSF (ConfigServer Security & Firewall)

The CSF, ConfigServer Security & Firewall, is a powerful firewall that is made for Linux...