书接上回,前面说到我被垃圾Rock 64搞的死去活来,索性在树莓派上装了Ubuntu 20.04 LTS。 为了方便配置V2Ray,我忙活了一天终于把LNMP环境搞定了。下面说说怎么搞的,避免后面再踩坑。
安装宝塔面板
在安装之前需要先安装必要的软件。Ubuntu 20.04 LTS上没有make和cmake,需要手动安装:
sudo apt-get install make -y
sudo apt-get install cmake -y
宝塔面板安装比较简单,官方提供的脚本如下:
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
执行过程中除了按一次y和回车外就是等,很简单。
安装LNMP环境
各软件版本
这个是本次的重中之重,需要解决的问题比较多。安装的各软件版本如下:Tengine Nginx
MySQL 5.6
Pure-ftpd 1.0.49
phpMyAdmin 4.7
PHP 7.2(也可以更高,PHP兼容性很好)
Pure-ftpd无法启动的解决办法
按照上图所示的方法打开设置界面,选择配置修改,找到TLS,把后面的1改成0。
Nginx安装前准备
树莓派上装Nginx非常麻烦,有很多东西需要配置,下面分步骤讲解:
安装LuaJIT(OpenResty版本)
cd ~/
wget -c -O luajit2-2.1-20200102.tar.gz https://github.com/openresty/luajit2/archive/v2.1-20200102.tar.gz -T 5
tar xvf luajit2-2.1-20200102.tar.gz
cd luajit2-2.1-20200102
sudo make
sudo make install
安装Lua Cjson(OpenResty版本)
cd ~/
wget -O lua-cjson-2.1.0.8rc1.tar.gz https://github.com/openresty/lua-cjson/archive/2.1.0.8rc1.tar.gz -T 5
tar xvf lua-cjson-2.1.0.8rc1.tar.gz
cd lua-cjson-2.1.0.8rc1
sudo make LUA_INCLUDE_DIR=/usr/local/include/luajit-2.1
sudo make install
修改Nginx安装脚本
sudo nano /www/server/panel/install/nginx.sh
找到LuaModVer,替换连续的两行为:
LuaModVer="0.10.16rc5"
wget -c -O lua-nginx-module-${LuaModVer}.zip https://github.com/openresty/lua-nginx-module/archive/v0.10.16rc5.zip -T 5
找到调用Install_LuaJIT和Install_cjson的地方,注释这两行,并加入下面两行:
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1/
保存并退出!
然后使用以下命令锁定该文件:
sudo chattr +i /www/server/panel/install/nginx.sh
如果你的树莓派上没有这个文件,可能是因为需要先安装一次才会出现,那就安装一次,我这除了Nginx和pure-ftpd别的都能运行,pure-ftpd就按照上面的方法解决,Nginx启动不了,先卸载再按这个步骤重新安装。
注意:Nginx要选Tengine,别的版本装不上,会报错。相信我,我都试过了!
上面的修改完了后,去网页上重新安装。
安装后配置
安装完Nginx后依然无法正常运行,会出现如下错误:
nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found:
no field package.preload['resty.core']
no file './resty/core.lua'
no file '/usr/local/share/luajit-2.1.0-beta3/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core.lua'
no file '/usr/local/share/lua/5.1/resty/core/init.lua'
no file './resty/core.so'
no file '/usr/local/lib/lua/5.1/resty/core.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './resty.so'
no file '/usr/local/lib/lua/5.1/resty.so'
no file '/usr/local/lib/lua/5.1/loadall.so') in /www/server/nginx/conf/nginx.conf:88
安装lua-resty-core
cd ~/
wget -c -O lua-resty-core.tar.gz https://github.com/openresty/lua-resty-core/archive/v0.1.18rc4.tar.gz -T 5
tar xvf lua-resty-core.tar.gz
cd lua-resty-core-0.1.18rc4
替换Makefile为如下内容:
OPENRESTY_PREFIX=/usr/local/openresty
#LUA_VERSION := 5.1
PREFIX ?= /usr/local
LUA_INCLUDE_DIR ?= $(PREFIX)/include
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL ?= install
.PHONY: all test install
all: ;
install: all
$(INSTALL) -d $(DESTDIR)$(LUA_LIB_DIR)/resty/core/
$(INSTALL) -d $(DESTDIR)$(LUA_LIB_DIR)/ngx/
$(INSTALL) -d $(DESTDIR)$(LUA_LIB_DIR)/ngx/ssl
$(INSTALL) lib/resty/*.lua $(DESTDIR)$(LUA_LIB_DIR)/resty/
$(INSTALL) lib/resty/core/*.lua $(DESTDIR)$(LUA_LIB_DIR)/resty/core/
$(INSTALL) lib/ngx/*.lua $(DESTDIR)$(LUA_LIB_DIR)/ngx/
$(INSTALL) lib/ngx/ssl/*.lua $(DESTDIR)$(LUA_LIB_DIR)/ngx/ssl/
$(INSTALL) lib/resty/*.lua /usr/local/share/luajit-2.1.0-beta3/resty/
$(INSTALL) lib/resty/core/*.lua /usr/local/share/luajit-2.1.0-beta3/resty/core/
test: all
PATH=$(OPENRESTY_PREFIX)/nginx/sbin:$$PATH prove -I../test-nginx/lib -r t
执行以下命令安装:
sudo make install
安装lua-resty-lrucache
cd ..
wget -c -O lua-resty-lrucache.tar.gz https://github.com/openresty/lua-resty-lrucache/archive/v0.10rc1.tar.gz -T 5
tar xvf lua-resty-lrucache.tar.gz
cd lua-resty-lrucache-0.10rc1
替换Makefile为如下内容:
OPENRESTY_PREFIX=/usr/local/openresty
PREFIX ?= /usr/local
LUA_INCLUDE_DIR ?= $(PREFIX)/include
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL ?= install
.PHONY: all test install lint
all: ;
install: all
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/resty/lrucache
$(INSTALL) lib/resty/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/resty/
$(INSTALL) lib/resty/lrucache/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/resty/lrucache/
$(INSTALL) lib/resty/*.lua /usr/local/share/luajit-2.1.0-beta3/resty/
$(INSTALL) lib/resty/lrucache/*.lua /usr/local/share/lua/5.1/resty/lrucache/
test: all lint
PATH=$(OPENRESTY_PREFIX)/nginx/sbin:$$PATH prove -I../test-nginx/lib -r t
lint:
@! grep -P -n --color -- 'require.*?resty\.lrucache[^.]' t/*pureffi*/*.t || (echo "ERROR: Found pureffi tests requiring 'resty.lrucache'." > /dev/stderr; exit 1)
@! grep -R -P -n --color --exclude-dir=pureffi --exclude=*mixed.t -- 'require.*?resty\.lrucache\.pureffi' t/*.t || (echo "ERROR: Found pure Lua tests requiring 'resty.lrucache.pureffi'." > /dev/stderr; exit 1)
执行以下命令安装:
sudo make install
完成后重启Nginx。推荐在网页上操作。
大功告成!开源爱好者 | Use it or lose it!blog.ee-fans.com