网站搜索

在 Debian 和 Ubuntu 上安装 OpenLiteSpeed、PHP 7 和 MariaDB


在上一篇文章中,我们描述了如何在 CentOS 7 上设置 OpenLiteSpeed(HTTP) 服务器、PHP 7 和 MariaDB。在本文中,我们将解释如何使用 PHP 7 和 MariaDB 安装和设置 OpenLiteSpeed – 高性能 HTTP Web 服务器支持 Debian 和 Ubuntu 系统。

OpenLiteSpeed是一个开源、高性能的HTTP服务器,具有事件驱动的架构;专为类 Unix 操作系统(包括 Linux 和 Windows 操作系统)而构建。

它是一个功能强大的模块化 HTTP 服务器,附带多个用于常见 HTTP 服务器功能的模块,可以处理数十万个并发连接,而不会出现严重的服务器负载问题,并且通过 API 支持第三方模块(LSIAPI)也是如此。

重要的是,它支持与 Apache 兼容的重写规则,附带一个易于使用、用户友好的 Web 管理控制台,可显示实时服务器统计信息。 OpenLiteSpeed 使用最少的 CPU 和内存资源,支持创建虚拟主机、高性能页面缓存以及安装不同的 PHP 版本。

第 1 步:启用 OpenLitespeed 存储库

1. OpenLiteSpeed 不存在于 Debian/Ubuntu 软件存储库中,因此您必须使用此命令添加 OpenLiteSpeed 存储库。这将创建文件 /etc/apt/sources.list.d/lst_debian_repo.list

wget -c http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh 
sudo bash enable_lst_debain_repo.sh

步骤 2:在 Debian/Ubuntu 上安装 OpenLiteSpeed

2. 然后使用下面的 apt 命令安装 OpenLiteSpeed 1.4(撰写本文时的最新版本),该命令会将其安装在 /usr/local 下/lsws 目录。安装完成后该服务也会启动。

sudo apt install openlitespeed

3.安装完成后,可以像这样运行来启动并确认OpenLiteSpeed版本

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

4. OpenLiteSpeed 默认运行在端口“8088”上。如果您在系统上启用了 UFW 防火墙,请更新防火墙规则以允许端口 8088 访问服务器上的默认站点。

sudo ufw allow 8088/tcp
sudo ufw reload

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

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

步骤 3:为 OpenLiteSpeed 安装 PHP 7

6. 接下来,使用以下命令安装 PHP 7 以及 OpenLiteSpeed 最需要的模块,它将把 PHP 安装为 /usr/local/lsws/lsphp70/bin /lsphp。

sudo apt install lsphp70 lsphp70-common lsphp70-mysql lsphp70-dev lsphp70-curl lsphp70-dbg

7. 如果您想安装额外的 PHP 模块,请运行以下命令列出所有可用的模块。

sudo apt install lsphp70-

步骤 4:配置 OpenLiteSpeed 和 PHP 7

8. 在本节中,我们将使用标准 HTTP 端口 80 配置 OpenLiteSpeed 和 PHP 7,如下所述。

正如我们之前提到的,OpenLiteSpeed 附带一个 WebAdmin 控制台,该控制台侦听端口 7080。因此,首先使用以下命令设置 OpenLiteSpeed WebAdmin 控制台的管理员用户名和密码。

sudo /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!

9. 现在添加防火墙规则以允许端口 7080 通过防火墙访问 WebAdmin 控制台。

sudo ufw allow 7080/tcp
sudo ufw reload

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

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

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

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

进入服务器配置外部应用→右侧添加按钮添加新的“lsphp70”,如图所示在下面的屏幕截图中。

12.然后定义新的外部应用程序,将类型设置为“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

请注意,这里最关键的配置是 Command 设置,它告诉外部应用程序在哪里找到它将使用的 PHP 可执行文件 - 提供 LSPHP70 的绝对路径:

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

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

13.接下来,点击服务器配置脚本处理程序并编辑默认的lsphp5脚本处理程序,输入以下内容价值观。

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

14. 默认情况下,大多数 HTTP 服务器与端口 80 关联或侦听,但 OpenLiteSpeed 默认情况下侦听 8080:将其更改为 80

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

将端口设置为80并保存配置并保存设置。

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

16.添加防火墙规则以允许端口80通过防火墙。

sudo ufw allow 80/tcp
sudo ufw reload

步骤 5:测试 PHP 7 和 OpenLiteSpeed 安装

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

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

18. 要管理和控制 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 数据库管理系统。

sudo apt install mariadb-server

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

sudo systemctl start mysql
sudo mysql_secure_installation

运行上面的安全脚本后,系统将提示您输入root密码,只需按[Enter]而不提供:

Enter current password for root (enter for none):

您还将被要求回答以下问题,只需在所有问题中输入 y 即可设置 root 密码、删除匿名用户、关闭远程 root 登录、删除测试数据库并重新加载权限表:

Set root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y

您可以从 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

就这样!在本教程中,我们解释了如何在 Debian/Ubuntu 系统上设置 OpenLiteSpeed、PHP 7 和 MariaDB。如果您有任何疑问或其他想法,请使用评论部分进行分享。


版权所有。 © Linux-Console.net • 2019-2024