在 Debian 上搭建 LAMP(Linux + Apache + MySQL/MariaDB + PHP)后,启服务通常用 systemd。下面按组件说明。
# 启动
sudo systemctl start apache2
# 停止
sudo systemctl stop apache2
# 重启
sudo systemctl restart apache2
# 开机自启
sudo systemctl enable apache2
# 查看状态
sudo systemctl status apache2
Debian 中 Apache 服务名是
apache2
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo systemctl status mariadb
sudo systemctl start mysql
sudo systemctl enable mysql
sudo systemctl status mysql
PHP 一般通过 Apache 模块或 PHP-FPM 运行:
sudo apt install php libapache2-mod-php
sudo systemctl restart apache2
sudo apt install php-fpm
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
systemctl status apache2 mariadb php-fpm
sudo ufw allow 80
sudo ufw allow 443
新建测试页:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
浏览器访问:
http://服务器IP/info.php
如果你愿意,我可以按 具体 Debian 版本(11/12) 或 是否用 Docker 给你更精确的命令。