Blog / Others/ Install and Configure OpenLiteSpeed with PHP 7 and MySQL 5.6

Install and Configure OpenLiteSpeed with PHP 7 and MySQL 5.6

安装openlitespeed服务器&PHP7&mysql5.6服务器

Installing OpenLiteSpeed Server

This guide covers the installation and configuration of OpenLiteSpeed, PHP 7, and MySQL 5.6.

Compiling OpenLiteSpeed from Source

If you choose to compile from source, follow these steps.

1. Install Required Components

Install the necessary dependency packages as outlined in the referenced article.

2. Compilation Options

You can fine-tune the installation using various ./configure options. If you are unfamiliar, using the default configuration is recommended.

Key optional features include:
--enable-adminssl=[yes/no]  # Enable HTTPS for admin console
--enable-http2=[yes/no]    # Enable HTTP/2 over HTTPS
--enable-debug             # Enable debugging symbols
--with-user=USER           # Set user to run OpenLiteSpeed [default: nobody]
--with-admin=USER          # Set admin username [default: admin]
--with-password=PASS       # Set admin password [default: 123456]
--with-openssl=DIR         # Root directory of OpenSSL installation

3. Compilation Notes

If using Google Cloud Shell with insufficient default user permissions, you may need to switch to the root user. Set the root password with sudo passwd root and then switch using su root before running compilation commands.

4. Open Firewall Ports

After installation, you may not be able to access the default ports 8088 (example page) and 7080 (admin interface) due to firewall rules. Add rules to allow TCP traffic on these ports. For example:

  • Rule Name: allow-openlitespeed-default-port
  • Protocol/Port: tcp:7080, tcp:8088
  • Source: 0.0.0.0/0 (or restrict to specific IPs for security)

Configuring OpenLiteSpeed Virtual Hosts

After accessing the admin console, configure your server as follows.

1. Create a Listener

Create a new listener named web on port 80.

2. Create a Virtual Host Template

First, create the template configuration file via SSH:

vi /usr/local/lsws/conf/templates/php-web.conf
chmod 777 /usr/local/lsws/conf/templates/php-web.conf

Then, in the admin panel, create a Virtual Host Template with these settings:

  • Template Name: php-web
  • Template File: $SERVER_ROOT/conf/templates/php-web.conf
  • Mapped Listeners: web

Save and restart the server.

3. Create a Virtual Host

Create the website root directory and host configuration file:

mkdir -p /wwwroot/html
chmod 755 /wwwroot /wwwroot/html
touch /usr/local/lsws/conf/vhosts/xxxx.conf
chmod 777 /usr/local/lsws/conf/vhosts/xxxx.conf

In the admin panel, create a Virtual Host with:

  • Document Root: $SERVER_ROOT/wwwroot/html/$VH_NAME
  • Configuration File: $SERVER_ROOT/conf/vhosts/$VH_NAME.conf

Finally, bind your domain to this virtual host under Listener web > General settings.

Installing PHP 7 via RPM Repository

1. Install Dependencies and PHP 7 Packages

Add the repository and install PHP 7.0 with common modules:

yum install epel-release -y
rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el6.noarch.rpm
yum install lsphp70 lsphp70-common lsphp70-gd lsphp70-process lsphp70-mbstring lsphp70-mysqlnd lsphp70-xml lsphp70-mcrypt lsphp70-pdo lsphp70-imap -y

The PHP binary will be located at /usr/local/lsws/lsphp70/bin/lsphp.

2. Configure PHP 7 in OpenLiteSpeed

In the admin console, navigate to Server Configuration > External App and add a LiteSpeed SAPI App. Use the following key configuration (other options can remain default):

Name: lsphp70
Address: uds://tmp/lshttpd/lsphp70.sock
Max Connections: 35
Environment: PHP_LSAPI_MAX_REQUESTS=500
           PHP_LSAPI_CHILDREN=35
Command: $SERVER_ROOT/lsphp70/bin/lsphp
Auto Start: yes

Save and restart the server.

3. Configure Script Handler

Navigate to WebAdmin console > Server > Script Handler. Edit the handler for the php suffix and set its Handler Name to lsphp70. Save and restart.

Note: The PHP 7 configuration file is located at /usr/local/lsws/lsphp70/etc/php.ini.

Compiling and Installing MySQL 5.6

1. Install Compilation Tools and Dependencies

yum install gcc gcc-c++ ncurses-devel perl -y

2. Install CMake

Download and compile CMake from source:

wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -xzvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap
make
make install
cd ~

3. Create MySQL User and Group

groupadd mysql
useradd -r -g mysql mysql

4. Create Installation and Data Directories

mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/mysqldb

5. Download and Compile MySQL

wget http://www.kakapart.com/files/mysql-5.6.16.tar.gz
tar -zxv -f mysql-5.6.16.tar.gz
cd mysql-5.6.16

Configure the build using CMake with key parameters:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DMYSQL_DATADIR=/usr/local/mysql/mysqldb 
-DMYSQL_TCP_PORT=3306

6. CMake Parameter Explanation

  • -DCMAKE_INSTALL_PREFIX: MySQL installation directory.
  • -DMYSQL_UNIX_ADDR: Path for the MySQL socket file.
  • -DDEFAULT_CHARSET: Server default character set.
  • -DDEFAULT_COLLATION: Server default collation.
  • -DWITH_*_STORAGE_ENGINE=1: Enable specific storage engines.
  • -DMYSQL_DATADIR: Directory for database files.
  • -DMYSQL_TCP_PORT: Port for MySQL service (default 3306).

After configuration, run make && make install to compile and install. Refer to MySQL official documentation for initialization, configuration, and startup steps.

Post a Comment

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