更新升级 专属应用 系统故障 硬件故障 电脑汽车 鸿蒙刷机 鸿蒙开发Linux教程 鸿蒙开发Linux命令
当前位置:HMXT之家 > 鸿蒙开发Linux教程 > 在RHEL 8/Rocky Linux 8上安装和配置OpenLiteSpeed

在RHEL 8/Rocky Linux 8上安装和配置OpenLiteSpeed

更新时间:2023-02-02 10:20:52浏览次数:247+次

本文介绍如何在RHEL 8/Rocky Linux 8系统上安装和配置OpenLiteSpeed的方法。OpenLiteSpeed是LiteSpeed Web服务器企业版的开源版本,它包含LiteSpeed Web Server Enterprise提供的基本功能。

简介

LightSpeed技术是一家知名的公司,生产开发完善、功能强大的LiteSpeed Web服务器。虽然与Apache相比,这家公司有点新,但它凭借轻量级、高性能和注重速度的web服务器而备受欢迎。

LiteSpeed Web服务器提供了许多惊人的功能,包括:

事件驱动体系结构–更少的流程、更少的开销,以及巨大的可扩展性。

HTTP/3和HTTP/2支持–为您的网站提供最新互联网协议的生产就绪实施。

智能缓存加速–它有一个内置的全页面缓存模块,可高度定制并高效实现卓越的用户体验。

一键安装–这允许用户只需单击一下即可安装WordPress、MariaDB和服务器。

PHP LiteSpeed SAPI–本机SAPI for PHP允许用PHP编写的外部应用程序运行速度提高50%。

用户友好的管理界面–它带有内置的WebAdmin GUI。CyberPanel提供控制面板支持。

从Apache升级–OpenLiteSpeed能够理解Apache重写规则。如果您使用过此web服务器,则可以轻松转换。

速度和安全性–它集成了强大的安全措施。这减轻了攻击和性能问题。这包括防DDoS连接和带宽限制、ModSecurity v3集成等。

在RHEL 8/Rocky Linux 8上安装OpenLiteSpeed的方法

本文提供了如何在RHEL 8/Rocky Linux 8上安装OpenLiteSpeed的两种方法,可从存储库安装(适用于Rocky Linux 8),或从二进制安装。

在开始安装之前,您需要将EPEL存储库添加到系统中:

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

现在继续使用最适合您的方法安装OpenLiteSpeed。

方法1、使用存储库在Rocky Linux 8上安装OpenLiteSpeed

使用此方法,您需要添加OpenLiteSpeed存储库,该存储库在RockyLinux8上提供OpenLiteSspeed包。

可以使用以下命令添加此存储库:

sudo rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.3-1.el8.noarch.rpm

样本输出:

Retrieving http://rpms.litespeedtech.com/centos/litespeed-repo-1.3-1.el8.noarch.rpm

Verifying...                          ################################# [100%]

Preparing...                          ################################# [100%]

Updating / installing...

   1:litespeed-repo-1.3-1.el8         ################################# [100%]

添加存储库后,继续并安装OpenLiteSpeed,如下所示:

sudo yum install openlitespeed

会安装openlitespeed x86_64包等。

方法2、从二进制文件在RHEL 8/Rocky Linux 8上安装OpenLiteSpeed

此方法需从OpenLiteSpeed下载页面中提取最新的或需要的OpenLiteSspeed存档文件,地址在https://openlitespeed.org/downloads/。也可以使用Wget提取此存档,也可以安装其他的版本,比如1.7.15等,如下所示:

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

下载后,将其解压缩:

tar -zxvf openlitespeed-*.tgz

现在导航到目录并安装OpenLiteSpeed:

cd openlitespeed

sudo ./install.sh

以下是详情:

Installing, please wait...

Admin SSL enabled!

download comamnd is wget -nv -O 

2023-02-01 07:35:35 URL:http://cyberpanel.sh/?ip [12] -> "/usr/local/lsws/myip" [1]

Generating a RSA private key

.................+++++

.................+++++

writing new private key to 'webadmin.key'

-----

SSL host is [webadmin], use adminSSL

download comamnd is wget -nv -O 

2023-02-01 07:35:38 URL:http://www.litespeedtech.com/packages/lsphp5_bin/x86_64/lsphp5 [4902224/4902224] -> "/usr/local/lsws/admin/fcgi-bin/admin_php" [1]

admin_php downloaded.

....

[OK] lshttpd.service has been successfully installed!

Updating webcache manager, please waiting ...

Downloading latest shared code tar file...

Checking tar file md5...

Removing existing shared code directory...

Extracting downloaded shared code...

Removing local shared code tar file...

Updating lscmctl script...

Done!

Installation finished, Enjoy!

Your webAdmin password is YThmYTBi, written to file /usr/local/lsws/adminpasswd.

安装完成后,您需要创建一个服务文件来管理OpenLiteSpeed。服务文件可以按如下方式创建:

cat <<EOF | sudo tee /etc/systemd/system/lsws.service

[Unit]

Description=Openlitespeed web server

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=simple

PIDFile=/tmp/lshttpd/lshttpd.pid

KillMode=none

PrivateTmp=false

User=root

Group=root

ExecStart=/usr/local/lsws/bin/lswsctrl start

ExecReload=/usr/local/lsws/bin/lswsctrl reload

ExecRestart=/usr/local/lsws/bin/lswsctrl restart

ExecStop=/usr/local/lsws/bin/lswsctrl stop

ExecStatus=/usr/local/lsws/bin/lswsctrl status

[Install]

WantedBy=multi-user.target

Alias=ols

EOF

重新加载系统守护程序:

sudo systemctl daemon-reload

在RHEL 8/Rocky Linux 8上启动OpenLiteSpeed

OpenLiteSpeed服务可以使用以下命令启动:

sudo systemctl start lsws

启用服务:

sudo systemctl enable lsws

检查服务是否正在运行:

$ systemctl status lsws

lshttpd.service - OpenLiteSpeed HTTP Server

接下来,允许OpenLiteSpeed服务通过防火墙:

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

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

sudo firewall-cmd --reload

创建OpenLiteSpeed管理密码及访问OpenLiteSpeed Web界面完成配置

设置用于登录OpenLiteSpeed管理员UI的管理员密码:

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]: admin

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!

就是这样,您已经设置了管理员用户和密码。

设置完以上,就可以访问OpenLiteSpeed Web界面了,请继续并使用URL访问在端口7080上运行的OpenLiteSpeed Web界面,地址格式为IP_address:7080或domain_name:7080:

\

使用创建的凭据登录并转到管理仪表板:

\

至此,在RHEL 8/Rocky Linux 8上安装和配置OpenLiteSpeed完成了。用户可以自由的使用OpenLiteSpeed托管Web应用程序或是在OpenLiteSpeed中创建示例Virtualhost等场景。