树莓宝塔php_记一次树莓派3B+安装宝塔面板及其他软件

本文详述了如何在树莓派3B+上安装宝塔面板以及配套的Nginx、MySQL 5.5和PHP 7.3。通过更换软件源、安装特定版本的LuaJIT和Lua Cjson,解决了OpenResty的兼容性问题,实现了在ARM架构上的稳定运行。
摘要由CSDN通过智能技术生成

前言

由于树莓派是ARM处理器,宝塔面板并没有说明支持ARM架构的系统,但宝塔是用Python写的,只要Python能运行,理论上宝塔也能运行。经过我多个版本的安装测试,最终找到了最适合的5.9.1。

成功安装宝塔面板只是第一步,我们使用宝塔面板就是为了方便管理其他的软件,例如Nginx、MySQL、PHP等等。然而直接在宝塔面板中安装这些软件并不会成功,还需要先安装其他的依赖库以及修改安装脚本。

安装前提

准备工作

修改系统软件源:sudo nano /etc/apt/sources.list#清华大学源

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse

添加pip软件源:sudo mkdir ~/.pip

sudo nano ~/.pip/pip.conf[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

升级系统软件:sudo apt-get update

sudo apt-get upgrade

重启系统:sudo reboot

开始安装

安装宝塔面板:cd ~/

wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh

安装LuaJIT(OpenResty版本):

建议安装OpenResty版本的LuaJIT2.1.0-beta3,与Tengine搭配性能最佳。cd ~/

wget -c -O luajit2-2.1-20190530.tar.gz https://github.com/openresty/luajit2/archive/v2.1-20190530.tar.gz -T 5

tar xvf luajit2-2.1-20190530.tar.gz

cd luajit2-2.1-20190530

sudo make

sudo make install

安装Lua Cjson(OpenResty版本):cd ~/

wget -O lua-cjson-2.1.0.7.tar.gz https://github.com/openresty/lua-cjson/archive/2.1.0.7.tar.gz -T 5

tar xvf lua-cjson-2.1.0.7.tar.gz

cd lua-cjson-2.1.0.7

sudo make LUA_INCLUDE_DIR=/usr/local/include/luajit-2.1

sudo make install

准备安装Nginx:

首先登录进入宝塔面板,在面板中安装Nginx,等待30秒左右,再关闭安装任务,此时在/www/server/panel/install目录中出现nginx.sh脚本。

修改脚本:sudo nano /www/server/panel/install/nginx.sh

第199行,改为LuaModVer="0.10.15"。

第200行,改为wget -c -O lua-nginx-module-${LuaModVer}.zip https://github.com/openresty/lua-nginx-module/archive/v0.10.15.zip -T 5。

第274行,注释掉Install_LuaJIT和Install_cjson,并另起两行分别加上export LUAJIT_LIB=/usr/local/lib和export LUAJIT_INC=/usr/local/include/luajit-2.1/。

安装Nginx(Tengine):cd /www/server/panel/install

sudo sh nginx.sh install

脚本执行完成没有失败提示即为成功,可在面板上找到已安装的Nginx Tengine。若出现错误警告,查看文末的问题解决。

安装MySQL 5.5:

树莓派的物理内存只有1G,被GPU占用掉一部分后只剩大概860MB,且编译MySQL需要使用大量内存,所以先检查虚拟内存是否足够,可以先临时设置1G大小,设置完成就可以编译了。编译时间较长,大约30分钟。cd /www/server/panel/install

sudo sh mysql.sh install 5.5

脚本执行完成没有失败提示即为成功,可在面板上找到已安装的MySQL 5.5。错误警告暂未发现。

安装PHP 7.3:

PHP可直接安装,仅安装测试了7.0+版本的,7.0以下的自行测试,感觉对ARM平台的兼容性还不错。cd /www/server/panel/install

sudo sh php.sh install 7.3

脚本执行完成没有失败提示即为成功,可在面板上找到已安装的PHP 7.3。错误警告暂未发现。

问题与解决

错误警告1:nginx: [error] lua_load_resty_core failed to load the module from https://github.com/openresty/******; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module '******' not found:……

产生原因:

缺少lua-resty-core和lua-resty-lrucache。

解决方法:

安装lua-resty-core和lua-resty-lrucache。由于官方安装包中的Makefile里写的安装路径与上面安装的Lua路径不同,所以我稍作修改后打包并上传了。cd ~/

wget -c -O lua-resty-core-0.1.17.tar.gz http://typecho.flasky.cn/usr/uploads/2019/06/1555442101.gz -T 5

tar xvf lua-resty-core-0.1.17.tar.gz

cd lua-resty-core-0.1.17

sudo make install

cd ..

wget -c -O lua-resty-lrucache-0.09.tar.gz http://typecho.flasky.cn/usr/uploads/2019/06/3553867893.gz -T 5

tar xvf lua-resty-lrucache-0.09.tar.gz

cd lua-resty-lrucache-0.09

sudo make install

最后重启Nginx即可。sudo /etc/init.d/nginx restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值