“远程访问 Debian LAMP”通常有两种理解:
下面分别说明,你可以按需求选择。
Debian 通常已安装 OpenSSH:
sudo apt update
sudo apt install openssh-server
sudo systemctl enable --now ssh
查看 IP:
ip a
ssh 用户名@服务器IP
示例:
ssh user@192.168.1.100
编辑配置:
sudo nano /etc/ssh/sshd_config
Port 2222
PermitRootLogin no
PasswordAuthentication no
然后:
sudo systemctl restart ssh
sudo apt install apache2 php libapache2-mod-php mysql-server
测试 Apache:
curl http://localhost
浏览器访问:
http://服务器IP
# 示例:frp / ngrok / cloudflare tunnel
Cloudflare Tunnel(推荐):
cloudflared tunnel --url http://localhost:80
默认 MySQL 只允许本地:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
sudo systemctl restart mysql
授权远程用户:
CREATE USER 'remote'@'%' IDENTIFIED BY '密码';
GRANT ALL PRIVILEGES ON *.* TO 'remote'@'%';
FLUSH PRIVILEGES;
⚠️ 建议通过 SSH 隧道访问 MySQL,而不是暴露 3306。
✅ SSH(密钥)
✅ Apache + HTTPS(Let’s Encrypt)
✅ 防火墙(ufw)
sudo ufw allow 22,80,443/tcp
sudo ufw enable
如果你能说明:
我可以直接给你一套最适合你的配置方案。