OpenLiteSpeed安装与使用-开源轻量高性能的建站面板-免费SSL,多PHP,LSCache

LiteSpeed是一款可以替换Apache的企业级Web服务器,具有高性能,低资源占用,安全,易用的特点。它支持直接使用Apache的配置文件,可直接使用.htacess,无需额外配置,兼容Mod_Security。因此避免像Nginx那样需要自己写重写规则的麻烦。

OpenLiteSpeed是LiteSpeed的开源免费版本,除了保留了LiteSpeed轻量、高性能的特性外,它还加入了非常多的“前沿”技术,例如HTTP3/QUIC/TLS1.3/Brotli等都是默认就支持的,而且LiteSpeed Cache 高性能缓存功能可以大大提升PHP的执行效率。

OpenLiteSpeed提供了一个服务器控制面板,这个控制面板可以让实现在线添加虚拟主机、绑定域名、设置端口号等建站操作,对于想要使用LiteSpeed来建站的朋友是一个非常好的平台。

OpenLiteSpeed安装与使用-开源轻量高性能的建站面板-免费SSL,多PHP切换,LiteSpeed Cache

更多的VPS控制面板请参考:服务器控制面板榜单。比较推荐用于建站的免费面板有:

  1. Oneinstack从入门到精通-Oneinstack安装与使用教程收集整理
  2. LNMP 1.6安装与使用-自动开启TLS 1.3和支持PHP 7.3\MariaDB 10.3
  3. 宝塔面板安装与使用图文教程-VPS新手建站必备工具丰富插件功能强大

PS:更新记录.

1、不想要使用Apache和Nginx,追求更高的OpenLiteSpeed和支持LSCache高性能缓存,请使用:CyberPanel免费开源面板-高速LSCache免费SSL证书-可自建DNS和企业邮局。2021.5.10

一、OpenLiteSpeed安装方法

网站:

  1. https://openlitespeed.org/

1.1 安装OLS

直接根据你自己的操作系统使用命令安装即可:

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,执行以下命令安装PHP 7.3:

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

主要是是否移除匿名登录、Root登录等,挖站否想保留Root登录所以选择的是n,你也可以自己选择y,以保证数据库的安全。

OpenLiteSpeed配置数据库
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启动程序

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

OpenLiteSpeed浏览器查看

2.2 登录OLS

修改OpenLiteSpeed登录账号和密码:

OpenLiteSpeed修改密码

然后打开OpenLiteSpeed的登录地址:IP:7080。

OpenLiteSpeed后台登录地址

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

OpenLiteSpeed管理面板界面

三、PHPMyAdmin安装管理

OpenLiteSpeed没有在线的数据库管理PHPMyAdmin,所以管理数据库都比较麻烦,我们可以自己安装一个。使用以下命令登录到你的数据库,创建一个数据库名:wzfou,密码为:wzfou.com 的数据库。(请替换为你自己的)

sudo mysql -u root -p

CREATE DATABASE wzfou CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES ON wzfou.* TO wzfou@localhost IDENTIFIED BY 'wzfou.com';
FLUSH PRIVILEGES;
quit
OpenLiteSpeed创建数据库

然后是下载并安装PHPMyAdmin了,使用以下命令:

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管理界面了。

OpenLiteSpeed在线管理数据库

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

OpenLiteSpeed登录Mysql

四、OpenLiteSpeed虚拟主机

4.1 开放80 443端口

点击监听器。

OpenLiteSpeed监听端口

然后添加80端口

OpenLiteSpeed开放80

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

OpenLiteSpeed开放443

4.2 新建虚拟主机

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

OpenLiteSpeed新建目录

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

OpenLiteSpeed默认目录

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

OpenLiteSpeed新建配置

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

OpenLiteSpeed配置根目录

4.3 设置默认首页

进入到OpenLiteSpeed的虚拟主机配置页面。

OpenLiteSpeed常规设置

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

OpenLiteSpeed默认首页

4.4 开启主机日志

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

OpenLiteSpeed错误日志

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

OpenLiteSpeed访问日志

4.5 开放网站访问

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

OpenLiteSpeed开放访问

4.6 启用地址重写

在虚拟主机“重写”一栏中开启重启和自动加载 .htaccess,这样你的网站就可以像Apache一样开启伪静态了。

OpenLiteSpeed地址重写

五、OpenLiteSpeed SSL证书

OpenLiteSpeed开启SSL证书非常地简单,这里我们以OpenLiteSpeed安装并配置letsencrypt免费SSL证书为例。关于acme.sh详细的教程请参考:简单三步给网站申请安装letsencrypt免费SSL证书-acme.sh自动续期

网站:

  1. https://letsencrypt.org/
  2. 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

签发成功后,你就可以得到你的Key和证书路径。

[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 
OpenLiteSpeed签发证书

回到你的服务器端口监听那里,找到443端口,把你刚刚生成的loco.wzfou.com.key 和loco.wzfou.com/fullchain.cer证书密钥和证书路径复制进去保存。

OpenLiteSpeed配置SSL证书

现以你就可以到你的虚拟主机的SSL管理那里,同样将loco.wzfou.com.key 和loco.wzfou.com/fullchain.cer证书密钥和证书路径复制进去保存。

OpenLiteSpeed虚拟主机SSL设置

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

OpenLiteSpeed优化SSL

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

OpenLiteSpeed正常使用SSL

六、OpenLiteSpeed切换PHP

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

OpenLiteSpeed添加新的PHP版本

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

OpenLiteSpeed调整路径

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

OpenLiteSpeed脚本处理器

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

OpenLiteSpeed调整PHP版本

需要提醒的是,如果你之前手动修改过某一个PHP的配置文件,当你切换了你的PHP版本后你的配置文件就会失效了,记得重新调整。各版本PHP配置路径如下:

七、LiteSpeed Cache 缓存

OpenLiteSpeed默认已经安装了LiteSpeed Cache 缓存,你在你的服务器模块那里就能看到。

OpenLiteSpeed开启缓存

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

OpenLiteSpeed WP插件

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

OpenLiteSpeed缓存成功

八、总结

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

OpenLiteSpeed重启服务器

这是OpenLiteSpeed的文件路径。

OpenLiteSpeed文件路径

文章出自:挖站否 https://wzfou.com/openlitespeed/,版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。


分享到:
Avatar for Qi
关于站长(Qi),2008年开始混迹于免费资源圈中,有幸结识了不少的草根站长。之后自己摸爬滚打潜心学习Web服务器、VPS、域名等,兴趣广泛,杂而不精,但愿将自己经验与心得分享出来与大家共勉。
已有 10 条评论
  1. Cyberpanel 有Web面板
    或者ols1clk (命令行

    2021年4月30日 23:12 回复
  2. cyberpanel好像也是openlitespeed
    这个面板还可以和whmcs对接自动开通虚拟主机

    2021年4月15日 14:18 回复
    • Avatar for Qi Qi

      是的,有专用的插件。

      2021年4月15日 18:50 回复
  3. Avatar for we we

    收藏一下,或许以后用得着。

    2021年4月11日 20:50 回复
  4. Avatar for 嘿嘿 嘿嘿

    LiteSpeed Cache Nginx fpmcache相比,哪个好一些?

    2021年4月9日 14:56 回复
    • Avatar for nweiooqo nweiooqo

      各有各的优点

      2021年4月9日 21:38 回复
  5. Avatar for 武子 武子

    OpenLiteSpeed不如Nginx用户多,经常出现莫名的问题。

    2021年4月9日 14:09 回复
  6. Avatar for 哟喂 哟喂

    刚上手时差点被这个面板搞瞎了,不过多试用几次就好了。

    2021年4月8日 12:22 回复
  7. Avatar for 罗小黑 罗小黑

    以前自己折腾成功过,还试过它的反代功能,现在宝塔也支持openlitespeed了,但宝塔进OLS的7080后台是不能操作的,支持openlitespeed的Cyber面板在操作和速度上还是不如宝塔简单快捷,不知道老外的设计思路是咋样的[黑线]

    2021年4月7日 22:49 回复
  8. 感觉还是宝塔在易用性方面比较有优势

    2021年4月7日 19:44 回复

Login

Welcome! Login in to your account

Remember me Lost your password?

Don't have account. Register

Lost Password

Register