How to install & Configure OpenLiteSpeed, php & MySQL on Fedora

In this tutorial we are going to install and configure OpenLiteSpeed web server, PHP and MySQL database server on Fedora. OpenLiteSpeed is a free and open source version of the LiteSpeed web server. This is a one of the best Apache web server alternative. It comes with apache rewrite rules support, GUI admin control panel and built-in cache support. For this tutorial i am using Fedora 31.

Install OpenLiteSpeed Web server On Fedora:

Open your terminal (ctrl+alt+T) and run this update command and update your Fedora system completely first.

sudo dnf update

Enter your Fedora user password.

Then install libnsl network service package using the below command. This provides the public client interface for NIS services.

sudo dnf install libnsl -y

If needed enter your Fedora password.

After that your need to start and configure the SSH, HTTP, HTTPS and 7080, 8088 ports on the firewall in Fedora. You can start it by using this command.

sudo systemctl start firewalld

Then enable the services and ports one by one using the below commands.

Enable SSH:

sudo firewall-cmd --permanent --add-service=ssh

Enable HTTP:

sudo firewall-cmd --permanent --add-service=http

Enable HTTPS:

sudo firewall-cmd --permanent --add-service=https

Enable Port 7080:

sudo firewall-cmd --permanent --add-port=7080/tcp

Enable Port 8088:

sudo firewall-cmd --permanent --add-port=8088/tcp

After that restart the firewall and enable firewall once again.

sudo firewall-cmd --reload
sudo systemctl enable firewalld

Download OpenLiteSpeed

Download the latest stable version of OpenLiteSpeed . Currently at the time of the Writing version 1.6.12 is stable version. In terminal run this command to download OpenLiteSpeed.

wget https://openlitespeed.org/packages/openlitespeed-1.6.12.tgz

Then extract the downloaded openlitespeed-1.6.12.tgz archive file using this command.

tar -zxvf openlitespeed-1.6.12.tgz

Then navigate to the extracted openlitespeed folder in terminal.

cd openlitespeed

Then run this below command to start the OpenLiteSpeed installation file.

sudo ./install.sh

Then start the OpenLiteSpeed Web server using below command.

sudo /usr/local/lsws/bin/lswsctrl start

you can check the web server status by using

sudo /usr/local/lsws/bin/lswsctrl status

In your browser go to the below address.

http://localhost:8088/

It will show the below OpenLiteSpeed Web server success page.

You can replace localhost with your ip or domain name.

http://<IP/DOMAINNAME>:8088

example: http://10.0.2.15:8088/

you can check your ip via below command.

ip a | grep inet

The default OpenLiteSpeed Web server directory is:

/usr/local/lsws/Example/html/

You should place the files in this directory to accessible over web.

Then run this command to set the Webserver Admin panel username and password.

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

To configure your webserver go to the below url in your browser.

https://localhost:7080/

or

https://<IP/DOMAINNAME>:7080

If you get the ssl error then click advanced and Accept the Risk and Continue.(firefox)

Install PHP on Fedora:

PHP 5.6:

OpenLiteSpeed Web server comes with PHP 5.6 by default and pre-enabled. If need this version of php, then you don’t need to do anything. You can check it with below url.

http://localhost:8088/phpinfo.php

You can install PHP from Fedora official repository and 3rd party Remi RMP Repository. Follow the below section to install PHP in these two methods.

Install PHP 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4: [Remi’s RPM repository method]

You can install PHP 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 from Remi RMP Repository. In this tutorial we are going to install latest PHP 7.4.

PHP 7.4:

First install the Remi RPM repository on Fedora.

sudo dnf -y install https://rpms.remirepo.net/fedora/remi-release-31.rpm

Here i am using fedora 31.

Suggested Read:  How to configure setup and install RPM Fusion on Fedora - 3rd-party software repository for Fedora

If you are using fedora 30 then,

sudo dnf -y install https://rpms.remirepo.net/fedora/remi-release-30.rpm

If you are using fedora 32 then,

sudo dnf -y install https://rpms.remirepo.net/fedora/remi-release-32.rpm

Then enable remi and remi-php74 repositories.

sudo dnf config-manager --set-enabled remi
sudo dnf config-manager --set-enabled remi-php74

Then disable the remi-modular repository.

sudo dnf config-manager --set-disabled remi-modular

Then install php using below command.

sudo dnf install php

Then install the required php extensions using below command.

sudo dnf install php-litespeed php-mysqlnd php-gd php-mcrypt php-bcmath php-zip php-devel php-curl php-pear

You can verify the installed version

php -v

PHP 7+: [FROM FEDORA REPOSITORY METHOD]

You can install PHP from the default Fedora repos. To check PHP package version, run this command.

dnf provides php

Currently it show php = 7.3.16. It differs based on the fedora version.
Fedora 31 provides PHP version 7.3 in its official repository.

If you want to install this version of PHP then run the below command to install it.

sudo dnf install php

Configure PHP:

PHP installed successfully now we need to configure php settings in our OpenLiteSpeed web server. Go to the OpenLiteSpeed admin panel and login with your username and password.

https://localhost:7080/

or

https://<IP/DOMAINNAME>:7080

Click on the Server Configuration from left side pane and select External App tab. The default entry is for PHP 5.6. We need to create new LiteSpeed App for PHP 7.4.

Click on the Add button from right side to create a new app.

For the type, select LiteSpeed SAPI App and click on Next.

Enter the below details on the fields and save it

Name: lsphp74
Address: uds://tmp/lshttpd/lsphp.sock
Max Connections: 40
Environment: PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=40
LSAPI_AVOID_FORK=200M
Initial Request Timeout (secs): 60
Retry Timeout : 0
Persistent Connection: Yes
Response Buffering: no
Start By Server: Yes(Through CGI Daemon)
Command: /usr/bin/lsphp
Back Log: 100
Instances: 1
Priority: 0
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes): 2047M
Process Soft Limit: 1400
Process Hard Limit: 1500

Go to the Script Handler tab and edit the lsphp handler. Switch the Handle name to lsphp74 from the drop-down menu.

Click Save and then restart the server by clicking on the Graceful restart button.

Then check the installed php version by visiting below url in your browser.

http://localhost:8088/phpinfo.php

Install MySQL on Fedora:

The latest version of MySQL is available from official Fedora repositories. Run this command in terminal to install it.

sudo dnf install community-mysql-server

You can enable mySQL server by running this command.

sudo systemctl enable mysqld

And start it by

sudo systemctl start mysqld

Then run this command to configure MySQL for the first time.

sudo mysql_secure_installation

Type Y and press the enter key. then choose your password strength by entering 0 or 1 or 2. example type 0 hit enter key. then set your mysql password minimum 8 characters and press enter.

Re-enter your password once again and hit enter.

Then press y and press enter.

Remove anonymous users? Press y and hit enter.

Disallow root login remotely? Type y hit enter.

Remove test database and access to it? Type y hit enter.

Reload privilege tables now?Type y hit enter.

Then you can login mysql using below command.

sudo mysql -u root -p

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on Twitter and Facebook.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *