记录CentOS环境部署免费OpenLiteSpeed引擎架设网站

我们大部分在部署网站环境的时候都是用的Nginx和Apache常规引擎,实际上我们还有很多的引擎可以用到,比如 免费的OpenLiteSpeed和付费的LiteSpeed。如果我们有需要可以用到"盘点常见10个VPS云服务器Web环境配置管理面板和一键脚本"文章中记录的一些常用的服务器面板脚本部署WEB环境,其中有我们可能熟悉的CyberPanel,采用的OpenLiteSpeed。

当然,如果我们有技术能力的,或者希望自己编译安装OpenLiteSpeed WEB环境的,可以通过这篇文章记录的方法。

1、安装OpenLiteSpeed

添加openliteSpeed存储库并从库中安装OpenLiteSpeed Web服务器。

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

我们还需要配置一下EPEL存储库,以便启用存储库,请运行以下命令。

dnf -y install epel-release

安装Openlitespeed

dnf install openlitespeed

过程中需要输入几次Y确认,一次是确认安装大小,然后好像是验证签名之类的东西了,总之都是Y。

启动并启用LiteSpeed

systemctl start lsws
systemctl enable lsws

2、安装lsphp8

本来需要配置一下EPEL存储库,但之前已经做过了,所以直接安装lsphp80

dnf -y install lsphp80

安装php扩展即extensions

dnf -y install lsphp80-mysqlnd lsphp80-gd lsphp80-process lsphp80-mbstring lsphp80-xml lsphp80-pdo lsphp80-imap lsphp80-soap lsphp80-bcmath lsphp80-zip

3、安装数据库MariaDB 10.5

添加MariaDB官方yum库

tee /etc/yum.repos.d/mariadb.repo<<EOF
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

或者通过 vim 按 i 把以上第二行起加入 /etc/yum.repos.d/mariadb.repo 中,版本号和系统是可以改的

清除并更新yum缓存,以检查mariadb库是否添加成功。

yum clean all 
yum makecache

安装MariaDB

dnf install mariadb mariadb-server

和安装php一样一路Y过去。启动并启用Mariadb。

systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb

MariaDB初始配置

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y

New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


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!

创建数据库,先登录进Mariadb的root用户

mysql -u root -p

输入密码后按照以下命令格式输入自己需要的数据库名字,用户名,以及密码,记得每一行代码后面要到英文格式的。

CREATE DATABASE database-name; 
CREATE USER database-username@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database-name.* TO database-username@localhost;
FLUSH PRIVILEGES;

假如数据库不再需要或者想换名字,删除原来的,用以下命令。

DROP DATABASE Database_name;
删除数据库,同时也要删除用户名:
DROP USER user@localhost; 
FLUSH PRIVILEGES;

重启mariadb服务:
systemctl restart mariadb

4、配置OpenLiteSpeed

OpenLiteSpeed可以通过图形操作后台来配置,也就是说这个服务器有个后台可登录进行设置,不过你需要打开后台管理页面的端口,默认7080, 设置后记得关闭此端口。

打开端口7080

firewall-cmd --add-port=7080/tcp --permanent              #打开端口
firewall-cmd --reload

firewall-cmd --remove-port=7080/tcp --permanent           #关闭端口             
firewall-cmd --reload

创建一个用户和密码并记录

需要先进入misc文件夹:
cd /usr/local/lsws/admin/misc
sh admpass.sh

打开浏览器,输入以下地址,登录LiteSpeed后台管理页面

你的主机IP加端口
http://yourIP:7080/

输入密码登陆进去,第一步需要连接上lsphp80(如果你用的是7.4版本,就都是lsphp74),默认litespeed连接的并非此版本。

总结,这里配置流程大约是这样子的,后面我们需要创建站点就可以使用。这里确实是比较复杂的,建议我们还是用一键脚本实现。

本文出处:老蒋部落 » 记录CentOS环境部署免费OpenLiteSpeed引擎架设网站 | 欢迎分享( 公众号:老蒋朋友圈 )

公众号 「老蒋朋友圈」获取站长新知 / 加QQ群 【1012423279】获取商家优惠推送