网站搜索

在 CentOS 7 上安装 OpenLiteSpeed (HTTP)、PHP 7 和 MariaDB


OpenLiteSpeed 是一款免费、开源、超轻量级 HTTP 服务器,适用于类 Unix 操作系统,包括 Linux 和 Windows 操作系统 - 由 LiteSpeed Technologies 设计。

它的功能丰富;高性能 HTTP 服务器,可用于管理数十万个同时连接,而不会出现严重的服务器负载问题,并且还通过 API (LSIAPI) 支持第三方模块。

OpenLiteSpeed 特点:

  • 高性能、事件驱动的架构。
  • 超轻量级,最少的 CPU 和内存资源。
  • 附带与 Apache 兼容的重写规则。
  • 用户友好的 WebAdmin GUI。
  • 支持众多模块以增强其功能。
  • 允许创建虚拟主机。
  • 支持高性能页面缓存。
  • 支持几个不同版本的PHP安装。

在本文中,我们将解释如何在 CentOS 7 上安装和配置具有 PHP 7 和 MariaDB 支持的 OpenLiteSpeed – 高性能 HTTP Web 服务器 RHEL 7

第 1 步:启用 OpenLitespeed 存储库

1. 首先安装并启用自己的 OpenLitespeed Repository,使用以下命令安装最新版本的 OpenLiteSpeedPHP 7

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

步骤 2:在 CentOS 7 上安装 OpenLiteSpeed

2. 现在使用下面的 YUM 包管理器命令安装 OpenLiteSpeed 1.4(撰写本文时的最新版本);这会将其安装在 /usr/local/lsws 目录下。

yum install openlitespeed

3.安装完成后,您可以通过运行来启动并确认OpenLiteSpeed版本。

/usr/local/lsws/bin/lswsctrl start
/usr/local/lsws/bin/lshttpd -v

4. 默认情况下,OpenLiteSpeed 运行在“8088”端口,因此您需要更新防火墙规则,允许8088端口通过防火墙访问 OpenLiteSpeed服务器上的默认站点。

firewall-cmd --zone=public --permanent --add-port=8088/tcp
firewall-cmd --reload

5. 现在打开 Web 浏览器并键入以下 URL 以验证 OpenLiteSpeed 的默认页面。

http://SERVER_IP:8088/ 
or 
http://localhost:8088

步骤 3:为 OpenLiteSpeed 安装 PHP 7

6. 在这里,您需要启用 EPEL 存储库,您将从中使用以下命令安装 PHP 7

yum install epel-release

7. 然后使用以下命令安装 PHP 7 和 OpenLiteSpeed 的一些必要模块,它将把 PHP 安装为 /usr/local/lsws/lsphp70/bin /lsphp。

yum install lsphp70 lsphp70-common lsphp70-mysqlnd lsphp70-process lsphp70-gd lsphp70-mbstring lsphp70-mcrypt lsphp70-opcache lsphp70-bcmath lsphp70-pdo lsphp70-xml

注意:你可能已经注意到,这里的PHP并没有按照通常的方式安装,你必须在它前面加上ls 因为 LiteSpeed 有一个独特的 PHP。

8. 要安装其他 PHP 模块,请使用以下命令列出所有可用的 PHP 模块。

yum search lsphp70
样本输出
Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager, versionlock
This system is not registered with Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
 * base: centos.mirror.snu.edu.in
 * epel: mirror.premi.st
 * extras: mirrors.nhanhoa.com
 * rpmforge: mirror.veriteknik.net.tr
 * updates: centos.mirror.snu.edu.in
=============================================================================================== N/S matched: lsphp70 ================================================================================================
lsphp70-debuginfo.x86_64 : Debug information for package lsphp70
lsphp70-pecl-igbinary-debuginfo.x86_64 : Debug information for package lsphp70-pecl-igbinary
lsphp70.x86_64 : PHP scripting language for creating dynamic web sites
lsphp70-bcmath.x86_64 : A module for PHP applications for using the bcmath library
lsphp70-common.x86_64 : Common files for PHP
lsphp70-dba.x86_64 : A database abstraction layer module for PHP applications
lsphp70-dbg.x86_64 : The interactive PHP debugger
lsphp70-devel.x86_64 : Files needed for building PHP extensions
lsphp70-enchant.x86_64 : Enchant spelling extension for PHP applications
lsphp70-gd.x86_64 : A module for PHP applications for using the gd graphics library
lsphp70-gmp.x86_64 : A module for PHP applications for using the GNU MP library
lsphp70-imap.x86_64 : A module for PHP applications that use IMAP
lsphp70-intl.x86_64 : Internationalization extension for PHP applications
lsphp70-json.x86_64 : JavaScript Object Notation extension for PHP
lsphp70-ldap.x86_64 : A module for PHP applications that use LDAP
lsphp70-mbstring.x86_64 : A module for PHP applications which need multi-byte s
...

步骤 4:配置 OpenLiteSpeed 和 PHP 7

9. 现在配置 OpenLiteSpeed 和 PHP 7,然后设置标准 HTTP 端口 80,如下所述。

正如我们之前提到的,OpenLiteSpeed 附带一个与端口 7080 关联的 WebAdmin 控制台。

首先配置 OpenLiteSpeed WebAdmin 控制台的管理员用户名和密码;运行以下命令来执行此操作:

/usr/local/lsws/admin/misc/admpass.sh
Please specify the user name of administrator.
This is the user name required to login the administration Web interface.

User name [admin]: tecmint

Please specify the administrator's password.
This is the password required to login the administration Web interface.

Password: 
Retype password: 
Administrator's username/password is updated successfully!

10.接下来更新防火墙规则以允许端口7080通过防火墙访问WebAdmin控制台。

firewall-cmd --zone=public --permanent --add-port=7080/tcp
firewall-cmd --reload

11. 现在打开 Web 浏览器并键入以下 URL 以访问 OpenLiteSpeed WebAdmin 控制台。

http://SERVER_IP:7080
OR
http://localhost:7080

输入您在上面设置的用户名和密码,然后单击“登录”。

12. OpenLiteSpeed 默认使用 LSPHP 5,您需要对设置 LSPHP 70 进行一些更改,如下所述。

为此,请转到右侧的服务器配置外部应用程序添加按钮添加新的“lsphp70” >”,如下面的屏幕截图所示。

13.然后定义外部应用程序,将类型设置为“LiteSpeed SAPI App”,然后单击“下一步”添加新外部应用程序的名称、地址、最大连接数、初始响应超时,并重试超时。

Name: 					lsphp70
Address:    				uds://tmp/lshttpd/lsphp.sock
Notes: 					LSPHP70 Configuration 
Max Connections: 			35
Initial Request Timeout (secs): 	60
Retry Timeout : 			0

这里最重要的配置是命令设置,它指示外部应用程序在哪里找到它将使用的PHP可执行文件;将其指向 LSPHP70 安装:

 Command: 	/usr/local/lsws/lsphp70/bin/lsphp	

然后点击保存按钮保存以上配置。

14. 接下来,单击服务器配置脚本处理程序并编辑默认的lsphp5脚本处理程序,使用值以下。完成后,保存设置。

Suffixes: 		php
Handler Type: 		LiteSpeed SAPI
Handler Name:		lsphp70
Notes:			lsphp70 script handler definition 

15. 默认端口 HTTP 服务器通常侦听端口 80,但对于 OpenLiteSpeed,它是 8080:将其更改为 80强>。

单击侦听器可查看所有侦听器配置的列表。然后单击查看以查看默认侦听器的所有设置,并单击编辑进行编辑。将端口设置为80并保存配置并保存设置。

16. 要反映上述更改,请单击重新启动按钮正常重新启动 OpenLiteSpeed,然后单击进行确认。

步骤 5:验证 PHP 7 和 OpenLiteSpeed 安装

17. 现在测试 OpenLiteSpeed 服务器是否正在侦听端口 80。修改防火墙规则以允许端口 80 通过防火墙。

firewall-cmd --zone=public --permanent --add-port=80/tcp
firewall-cmd --reload 

18. 最后使用以下 URL 验证 OpenLiteSpeed 是否在端口 80 和 PHP 7 上运行。

http://SERVER_IP
http://SERVER_IP/phpinfo.php 

19. 要管理和控制 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

第 6 步:安装 MariaDB for OpenLiteSpeed

20. 使用以下命令安装 MariaDB 数据库管理系统。

yum install openlitespeed mariadb-server

21. 接下来,启动 MariaDB 数据库系统并保护其安装。

systemctl start mariadb
mysql_secure_installation

首先,它会要求您提供 MariaDB root 密码,只需按 ENTER 键设置新的 root 密码并确认。对于其他问题,只需按 ENTER 键接受默认设置。

您可以从 OpenLitespeed 主页找到更多信息:http://open.litespeedtech.com/mediawiki/

您还可以关注相关文章。

  1. 在 RHEL/CentOS 7.0 中安装 LAMP(Linux、Apache、MariaDB、PHP/PhpMyAdmin)
  2. 在 RHEL/CentOS 7/6 上安装最新的 Nginx 1.10.1、MariaDB 10 和 PHP 5.5/5.6
  3. 如何在 16.10/16.04 中安装 Nginx、MariaDB 10、PHP 7 (LEMP Stack)
  4. 如何在 Ubuntu 16.10 上使用 PHP 7 和 MariaDB 10 安装 LAMP

在本文中,我们向您解释了在 CentOS 7 系统上使用 PHP 7 和 MariaDB 安装和配置 OpenLiteSpeed 的步骤。

我们希望一切顺利,否则请通过下面的评论部分向我们发送您的疑问或任何想法。