装 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 即可访问网站。
后续也可以内网穿透来公网访问,根据个人喜好来安装吧!