Powerfull Webserver Centos 7 Openlitespeed with MultiPHP and Mariadb

*This is my raw note for configuration webserver centos with openlitespeed.

====== POWERFULL SERVER CENTOS 7 OPENLITESPEED WITH MULTIPLE PHP + MARIADB ===========

STEP 1 : INSTALLING OPENLITESPEED

1. INSTALL REPO
# rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm

2. INSTALL OPENLITESPEED
# yum install openlitespeed

3. START OPENLITESPEED
# /usr/local/lsws/bin/lswsctrl start
# /usr/local/lsws/bin/lshttpd -v

4. AKTIFKAN PORT WEBSITE
# firewall-cmd --zone=public --permanent --add-port=8088/tcp
# firewall-cmd --zone=public --permanent --add-port=7080/tcp
# firewall-cmd --zone=public --permanent --add-port=80/tcp
# firewall-cmd --reload

5. TES OPENLITESPEED
http://SERVER_IP:8088/

6. BUAT PASSWORD PANEL
# /usr/local/lsws/admin/misc/admpass.sh

7. TES PANEL
http://SERVER_IP:8070/

STEP 2 : INSTALL PHP

1. INSTALL REPO
# yum install epel-release

2. INSTALL PHP
# yum groupinstall lsphp-all

+++++ COMMAND DIRECTORY PHP VERSION +++
===================================
/usr/local/lsws/lsphp52/bin/lsphp
/usr/local/lsws/lsphp53/bin/lsphp
/usr/local/lsws/lsphp54/bin/lsphp
/usr/local/lsws/lsphp55/bin/lsphp
/usr/local/lsws/lsphp56/bin/lsphp
/usr/local/lsws/lsphp70/bin/lsphp
===================================

3. TAMBAHKAN PHP 7 DLL DI SERVERCONFIGURATION
Click Add on WebAdmin console > Server Configuration > External App > Add
Select LiteSpeed ​​SAPI App
===================================
Name: lsphp70
Address:    uds://tmp/lshttpd/lsphp.sock
Notes: LSPHP70 Configuration
Max Connections: 60
Initial Request Timeout (secs): 90
Retry Timeout : 0
Command: /usr/local/lsws/lsphp70/bin/lsphp
===================================

4. TAMBAHKAN SCRIPTHANDLER PHP7
click on Server Configuration → Script Handler > Add
===================================
Suffixes: php
Handler Type: LiteSpeed SAPI
Handler Name: lsphp70
Notes: lsphp70 script handler definition
===================================

STEP 3 : SETUP SERVER AND VIRTUALHOST

1. GANTI LISTENER SERVER 8080 KE 80
Click on Listeners to see a list of all listeners configurations. Then click View to see all settings of the default listener and to edit, click Edit. Set the port to 80 and save the configuration and save the settings.

2. GRACEFULL RESTART

3. KONTROL OPENLITESPEED
=============================================================================================
# /usr/local/lsws/bin/lswsctrl start #start OpenLiteSpeed
# /usr/local/lsws/bin/lswsctrl stop    #Stop OpenLiteSpeed
# /usr/local/lsws/bin/lswsctrl restart #gracefully restart OpenLiteSpeed (zero downtime)
# /usr/local/lsws/bin/lswsctrl help #show OpenLiteSpeed commands
=============================================================================================

4. TAMBAHKAN VIRTUALHOST
KLIK MENU VIRTUALHOST > Add
=====================================================================
Virtual Host Name php7.domain.com
Virtual Host Root $SERVER_ROOT/php7.domain.com/
Config File $SERVER_ROOT/conf/vhosts/$VH_NAME/php7.domain.com.conf
Follow Symbolic Link Yes
Enable Scripts/ExtApps Yes
Restrained Yes
ExtApp Set UID Mode Server UID
=====================================================================

5. SETUP VIRTUALHOST
Virtual Hosts –> Choose Virtual Host (php7.domain.com) –> General MENU > GENERAL > Edit
===============================
Document Root $VH_ROOT/html/
Domain Name php7.domain.com
Enable GZIP Compression Yes
===============================

Virtual Hosts –> Choose Virtual Host (php7.domain.com) –> General –> Index Files.
===================================
Use Server Index Files No
Index Files index.html
Auto Index No
===================================

Virtual Hosts –> Choose Virtual Host (php7.domain.com) –> Log —> Virtual Host Log.
================================================
Use Server’s Log Yes
File Name $VH_ROOT/logs/error.log
Log Level ERROR
Rolling Size (bytes) 10M
================================================

Virtual Hosts –> Choose Virtual Host (php7.domain.com) –> Log –> Access Log.
===================================================
Log Control Own Log File
File Name $VH_ROOT/logs/access.log
Piped Logger Not Set
Log Format Not Set
Log Headers Not Set
Rolling Size (bytes) 10M
Keep Days 30
Bytes log Not Set
Compress Archive Yes
===================================================

Virtual Hosts –> Choose Virtual Host (php7.domain.com) –> Security.
==================
Allowed List *
==================

(JIKA MENGGUNAKAN PHP7 GUNAKAN LANGKAH INI, JIKA INGIN MENGGUNAKAN PHP5.6 LEWATI LANGKAH INI)
Virtual Hosts –> Choose Virtual Host (php7.domain.com) –> SCRIPTHANDLER
===================================
Suffixes: php
Handler Type: LiteSpeed SAPI
Handler Name: [Server Level]lsphp70
Notes: lsphp70 script handler definition
===================================

6. MAPPING VIRTUALHOST KE Listeners
Listeners and click on Zoom icon view the Default listener.
add virtual host mapping.
==================================
Virtual Host php7.domain.com
Domains php7.domain.com
==================================

7. BUAT DOCUMENTROOT WEBSITE
# mkdir /usr/local/lsws/php7.domain.com/
# mkdir /usr/local/lsws/php7.domain.com/logs
# mkdir /usr/local/lsws/php7.domain.com/html
# echo "<?php phpinfo(); ?>" > /usr/local/lsws/php7.domain.com/html/index.html

8. GRACEFULLY RESTART

9. CEK VIRTUALHOST
http://php7.domain.com

STEP 4 : INSTALL MARIADB
# yum install openlitespeed mariadb-server
# systemctl start mariadb
# mysql_secure_installation

=================BONUS=================
WORDPRESS + LSCACHE
1. INSTALL WORDPRESS
2. INSTALL LiteSpeed Cache Plugin


# chown -R nobody:nobody /html

wp-config.php = define('FS_METHOD','direct');

======================= HTACCESS REWRITE RULE ====================
OpenLiteSpeed Webadmin > VirtualHost > Edit your vhost > Context tab. After that, create a new static context. The fields that need to be edited are:

URI – /
Location – $VH_ROOT/html/
Accessible – Yes
Enable Rewrite – Yes
Rewrite Rules – Put the rewrite rules here