在 Debian 系统上安装 LAMP(Linux, Apache, MySQL, PHP)环境的步骤如下:
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
http://localhost
查看默认的 Apache 信息页面。Debian 12 软件源中包含的是 MariaDB,它完全兼容 MySQL。
sudo apt update
sudo apt install mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
mysql -u root -p
sudo apt update
sudo apt install php libapache2-mod-php php-mysql php-fpm
sudo systemctl restart apache2
sudo nano /var/www/html/phpinfo.php
在文件中输入以下内容:
<?php phpinfo(); ?>
保存并退出,然后在浏览器中输入 http://your_server_ip/phpinfo.php
查看 PHP 信息页面。
sudo nano /etc/apache2/sites-available/000-default.conf
添加以下配置:
ServerName your_domain.com
Redirect permanent / https://your_domain.com/
sudo a2ensite default-ssl
sudo systemctl reload apache2
sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/your_domain.com.conf
替换配置文件中的 your_domain.com
为你的实际域名,并上传相应的 SSL 证书文件。
sudo apt install phpmyadmin
http://your_server_ip/phpmyadmin
以访问 phpMyAdmin 界面。以上步骤完成后,你就成功在 Debian 系统上搭建了一个基本的 LAMP 环境。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:Debian LAMP如何更新维护