随身WIFI板子安装LNMP教程

😂 这篇文章最后更新于391天前,您需要注意相关的内容是否还可用。

装LNMP,准备工作

# 连wifi
nmtui
# 更新源
apt-get update
# 装ssl证书
sudo apt install apt-transport-https ca-certificates
# 修改源文件权限 使其能用xftp直接编辑
chmod 777 /etc/apt/sources.list

sources.list源内容,可根据个人喜好选择源

# deb http://mirrors.163.com/debian/ bullseye main contrib non-free
# deb http://security.debian.org/ bullseye-security main contrib non-free
# 默认注释了源码镜像以提高 apt update 速度
# 清华大学的软件源
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free 
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free 
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

# 阿里云的软件源
# deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
# deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
# deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

# 中科大的软件源
# deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free 
# deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free 
# deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free 
# deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free 
# deb-src https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free

继续执行命令安装PHP、Nginx

apt-get update
apt-get upgrade
# 安装PHP拓展
sudo apt-get install -y php php-fpm php-curl php-gd php-intl php-mbstring php-mysql php-imap php-opcache php-sqlite3 php-xml php-xmlrpc php-zip
# 查看php版本 验证是否成功
php -v
sudo apt-get install nginx
# 验证nginx是否成功 安装curl、nano编辑器、wget
apt-get install curl nano wget
curl 127.0.0.1
# 找到index配置,添加index.php
sudo nano /etc/nginx/sites-enabled/default

找到# pass PHP scripts to FastCGI server后面的location 删除注释如下

location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}

重启nginx 验证php

sudo systemctl restart nginx
sudo nano /var/www/html/phpinfo.php

新建phpinfo.php文件验证,文件内容为

<?php
phpinfo();

电脑浏览器访问:http://192.168.68.1/phpinfo.php 即可看到PHP探针信息。

安装MySql

sudo apt-get install mariadb-server mariadb-client
sudo mysql_secure_installation
# 参考
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
# 将bind-address这行注释掉
# 或者将127.0.0.1 这个值改为  0.0.0.0
# 然后重启
sudo systemctl restart mariadb.service

设置远程访问权限

mysql -u root -p
use mysql;
# 例如账号root 密码rootpwd
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'rootpwd' WITH GRANT OPTION;
flush privileges;
# ctrl + c 退出界面,执行命令重启服务
sudo systemctl restart mariadb.service
# 查看mysql服务状态
sudo systemctl status mariadb.service

安装Z-Blog示例

cd /var/www/html/
# 上传程序包到该目录
wget https://update.zblogcn.com/zip/Z-BlogPHP_1_7_2_3060_Tenet.zip
unzip Z-BlogPHP_1_7_2_3060_Tenet.zip
# 返回上一级,将网站目录文件全部授权777(个人之便)
cd ..
chmod -R 777 ./html

然后访问:http://192.168.68.1 即可安装网站程序。执行命令:ip addr 获取棒子连接WIFI的地址,记下来会用到。
拔掉随身WIFI随便插在某个插头上,等几分钟后访问 ip addr 获取的ip即可访问网站。
后续也可以内网穿透来公网访问,根据个人喜好来安装吧!