OpenLiteSpeed安装与使用-开源轻量高性能的建站面板-免费SSL,多PHP,LSCache
LiteSpeed是一款可以替换Apache的企业级Web服务器,具有高性能,低资源占用,安全,易用的特点。这里的企业版LiteSpeed与OpenLiteSpeed要分开看:不能把企业版对Apache的兼容性原样套给OLS。OLS可加载部分.htaccess重写规则,但不支持把Apache完整配置和所有指令直接照搬。因此避免像Nginx那样需要自己写重写规则的麻烦。
而OpenLiteSpeed是LiteSpeed的开源免费版本,除了保留了LiteSpeed轻量、高性能的特性外,它还加入了非常多的“前沿”技术,例如HTTP3/QUIC/TLS1.3/Brotli等都是默认就支持的,而且LiteSpeed Cache 高性能缓存功能可以大大提升PHP的执行效率。
OpenLiteSpeed提供了一个服务器控制面板,这个控制面板可以让实现在线添加虚拟主机、绑定域名、设置端口号等建站操作,对于想要使用LiteSpeed来建站的朋友是一个非常好的平台。

更多的VPS控制面板请参考:服务器控制面板榜单。比较推荐用于建站的免费面板有:
- Oneinstack从入门到精通-Oneinstack安装与使用教程收集整理
- LNMP 1.6安装与使用-自动开启TLS 1.3和支持PHP 7.3\MariaDB 10.3
- 宝塔面板安装与使用图文教程-VPS新手建站必备工具丰富插件功能强大
PS:2026年11月13日更新,更新 OLS 安装与 PHP 版本说明,补充新版 WebAdmin 入口,修正数据库授权、SSL 部署和重写兼容范围。
PS:更新记录.
1、不想要使用Apache和Nginx,追求更高的OpenLiteSpeed和支持LSCache高性能缓存,请使用:CyberPanel免费开源面板-高速LSCache免费SSL证书-可自建DNS和企业邮局。2021.5.10
一、OpenLiteSpeed安装方法
网站:
- https://openlitespeed.org/
1.1 安装OLS
下面的CentOS 5—8、Debian 7/8和早期Ubuntu命令保留作历史记录,这些系统不应继续作为新装默认环境。当前请先按官方支持系统和仓库文档安装,不要直接执行旧HTTP源脚本:https://docs.openlitespeed.org/installation/repo/
CentOS 5: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el5.noarch.rpm CentOS 6: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el6.noarch.rpm CentOS 7: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm CentOS 8: rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm Debian 7, 8 & Ubuntu 12,14,16,18 : wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debian_repo.sh | bash For CentOS: yum install openlitespeed For Debian & Ubuntu: apt-get install openlitespeed
1.2 安装PHP
默认的OpenLiteSpeed默认版本取决于安装方式;以下PHP7.3/7.4已是历史示例,不适合新站直接使用。当前先查仓库提供的受支持LSPHP版本和应用兼容性,再按官方方式安装扩展及设置脚本处理器:https://docs.openlitespeed.org/config/php/ 。原命令如下:
For CentOS: yum install epel-release yum install lsphp73 lsphp73-common lsphp73-mysql lsphp73-gd lsphp73-process lsphp73-mbstring lsphp73-xml lsphp73-mcrypt lsphp73-pdo lsphp73-imap lsphp73-soap lsphp73-bcmath ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5 For Debian & Ubuntu: apt-get install lsphp73 ln -sf /usr/local/lsws/lsphp73/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5
想要安装多个PHP的,可以使用以下命令安装(想要哪个版本只要替换一下数字就行):
apt-get install lsphp74 ln -sf /usr/local/lsws/lsphp74/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5 #If you wish to install an older version such as PHP 5.6, replace lsphp73 to lsphp56.
1.3 安装数据库
执行以下命令安装mariadb数据库。
sudo apt-get install mariadb-server mariadb-client
执行以下命令对数据库进行安全设置。
mysql_secure_installation
下面是当时MariaDB交互记录。Disallow root login remotely只控制远程root登录,不等于禁止本机root管理;新环境按实际认证方式配置,业务使用专用账户,不照抄旧示例选择。

root@ecs-OA5Ok:~# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
重启或者关闭数据库。
systemctl start mariadb systemctl restart mariadb
二、OpenLiteSpeed面板使用
2.1 启动OLS
执行以下命令启动或者停止OpenLiteSpeed。

打开你的OpenLiteSpeed,地址是:IP:8088,你可以看到你的OpenLiteSpeed运行成功了。

2.2 登录OLS
修改OpenLiteSpeed登录账号和密码:

管理地址使用 https://服务器地址:7080/,与示例网站端口8088不同。官方说明从OLS1.9.4起WebAdmin默认关闭,出现Disabled页面应按对应版本文档启用并限制允许IP;需要重设管理员密码时用 /usr/local/lsws/admin/misc/admpass.sh,不要误以为网站8088可访问就代表管理控制台已开放。

这个就是OpenLiteSpeed的后台管理面板,主要有主面板、服务器、监听器、虚拟主机、虚拟主机模板、工具、管理控制台设置等。(点击放大)

三、PHPMyAdmin安装管理
OpenLiteSpeed没有在线的数据库管理PHPMyAdmin,所以管理数据库都比较麻烦,我们可以自己安装一个。使用以下命令登录到你的数据库,创建一个数据库名:wzfou,密码为:wzfou.com 的数据库。(请替换为你自己的)
sudo mysql -u root -p CREATE DATABASE wzfou CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'wzfou'@'localhost' IDENTIFIED BY '请替换为独立随机密码'; GRANT ALL PRIVILEGES ON wzfou.* TO 'wzfou'@'localhost'; FLUSH PRIVILEGES; quit

下方phpMyAdmin4.9.7包及截图仅供旧版参考。新安装应从 https://www.phpmyadmin.net/downloads/ 选择与当前PHP兼容的受支持版本并核验来源,不要把旧包作为生产默认;管理页面应使用HTTPS并限制访问。
cd /usr/local/lsws/Example/html wget https://files.phpmyadmin.net/phpMyAdmin/4.9.7/phpMyAdmin-4.9.7-all-languages.zip #apt install unzip unzip phpMyAdmin-4.9.7-all-languages.zip mv phpMyAdmin-4.9.7-all-languages phpmyadmin
现在打开地址:http://server_IP:8088/phpmyadmin/index.php,你就可以看到PHPMyAdmin管理界面了。

使用上面创建的数据库用户名和密码(如果你没有禁用Root,也可以使用Root登录)登录到PHPMyAdmin。

四、OpenLiteSpeed虚拟主机
4.1 开放80 443端口
点击监听器。

然后添加80端口

按照同样的方法同时也开通443端口,选择加密连接。

4.2 新建虚拟主机
进入到你的VPS主机路径:/usr/local/lsws/,创建文件夹wzfoumm,然后在文件夹里创建html和log两个文件夹。如下图:

然后点击添加虚拟主机,设置好网站的根目录:wzfoumm,配置文件路径:conf/vhosts/wzfoumm/vhconf.conf,开启启用外部应用程序,其它的请参考OpenLiteSpeed默认的网站配置即可。

配置文件会提示路径不存在,你直接点击新建就会自动生成了。

设置网站根目录,绑定好你的域名。

4.3 设置默认首页
进入到OpenLiteSpeed的虚拟主机配置页面。

然后在索引文件那里输入你想要默认的首页文件,一般地是:index.php,index.html。

4.4 开启主机日志
开启服务器错误日志,可以设置大小,是否切割,保留多少天数,如下图:

开启服务器访问日志,如下图:

4.5 开放网站访问
在网站的“安全”一项,在允许列表中输入:*,表示你允许所有访问,当然这里也可以添加拒绝访问的IP或者IP段。

4.6 启用地址重写
在虚拟主机重写设置中启用重写及Auto Load from .htaccess。它只加载支持的重写指令,不代表全部Apache配置兼容;修改后按OLS文档执行平滑重启并验证实际路径。

五、OpenLiteSpeed SSL证书
OpenLiteSpeed开启SSL证书非常地简单,这里我们以OpenLiteSpeed安装并配置letsencrypt免费SSL证书为例。关于acme.sh详细的教程请参考:简单三步给网站申请安装letsencrypt免费SSL证书-acme.sh自动续期。
网站:
- https://letsencrypt.org/
- https://github.com/Neilpang/acme.sh
使用以下可以一键安装:
curl https://get.acme.sh | sh
或者:
wget -O - https://get.acme.sh | sh
使用喜欢Git命令也可以用以下命令安装:
git clone https://github.com/Neilpang/acme.sh.git cd ./acme.sh ./acme.sh --install
然后使用以下命令签发域名SSL证书:
acme.sh --issue -d loco.wzfou.me -w /usr/local/lsws/wzfoumm/html
下方保留2021年的签发输出。当前acme.sh应使用install-cert把证书安装到稳定的服务路径并配置reloadcmd,不直接依赖内部签发目录;如明确需要Let’s Encrypt,应显式选择相应CA。续期成功后还要核对服务实际加载的新证书。
[Sat Jan 23 02:50:47 UTC 2021] Your cert is in /root/.acme.sh/loco.wzfou.me/loco.wzfou.me.cer [Sat Jan 23 02:50:47 UTC 2021] Your cert key is in /root/.acme.sh/loco.wzfou.me/loco.wzfou.me.key [Sat Jan 23 02:50:47 UTC 2021] The intermediate CA cert is in /root/.acme.sh/loco.wzfou.me/ca.cer [Sat Jan 23 02:50:47 UTC 2021] And the full chain certs is there: /root/.acme.sh/loco.wzfou.me/fullchain.cer

回到你的服务器端口监听那里,找到443端口,把你刚刚生成的实际部署目录中的私钥文件和 fullchain 证书文件证书密钥和证书路径复制进去保存。

现以你就可以到你的虚拟主机的SSL管理那里,同样将实际部署目录中的私钥文件和 fullchain 证书文件证书密钥和证书路径复制进去保存。

另外,对于SSL你还可以进入一系列的自定义,例如SSL重新协商保护、启用会话缓存、启用会话单、启用SPDY/HTTP2、Enable QUIC等系列操作。

重启你的OpenLiteSpeed,打开你的浏览器你就可以看到letsencrypt免费SSL证书安装成功了。

六、OpenLiteSpeed切换PHP
首先,你需要安装多个PHP版本,方法请参考上面第一部分安装PHP部分,然后到你的服务器设置那里,添加 外部应用程序。

然后添加另一个PHP外部应用程序就行了,参数直接参考OpenLiteSpeed默认生成的那个PHP版本就行了,只不把路径调整一下,例如lsphp72/bin/lsphp,lsphp73/bin/lsphp,lsphp74/bin/lsphp等。

添加完成后,到你的虚拟主机的“脚本处理器”那里,添加PHP脚本语言处理器为你刚刚添加的外部程序即可。

重启你的OpenLiteSpeed,然后你就可以看到你的虚拟主机已经切换了另外一个PHP版本了。

需要提醒的是,如果你之前手动修改过某一个PHP的配置文件,当你切换了你的PHP版本后你的配置文件就会失效了,记得重新调整。各版本PHP配置路径如下:
七、LiteSpeed Cache 缓存
OpenLiteSpeed默认已经安装了LiteSpeed Cache 缓存,你在你的服务器模块那里就能看到。

LiteSpeed Cache为Wordpress,Xenforo,Magento,Joomla等知名PHP软件提供高效高性能的缓存功能,安装Wordpress LiteSpeed Cache 插件就可以启用了。

LiteSpeed Cache 为Wordpress提供动态优化加速服务,你可以在代码中看到缓存是否成功。

八、总结
OpenLiteSpeed提供的建站功能非常强大,你可以自由地对PHP、数据库、域名绑定、虚拟主机、SSL证书等进行自定义,不过所有的操作都需要重启OpenLiteSpeed后才可以生效。

这是OpenLiteSpeed的文件路径。

文章出自:挖站否 https://wzfou.com/openlitespeed/,版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。
猜你喜欢
-
Cyberpanel 有Web面板
或者ols1clk (命令行2021年4月30日 23:12 -
收藏一下,或许以后用得着。
2021年4月11日 20:50 -
LiteSpeed Cache Nginx fpmcache相比,哪个好一些?
2021年4月9日 14:56-
各有各的优点
2021年4月9日 21:38
-
-
OpenLiteSpeed不如Nginx用户多,经常出现莫名的问题。
2021年4月9日 14:09 -
刚上手时差点被这个面板搞瞎了,不过多试用几次就好了。
2021年4月8日 12:22 -
感觉还是宝塔在易用性方面比较有优势
2021年4月7日 19:44















我的博客现在用的是这个,非常不错。