1、安装APACHE2和MYSQL
sudo apt-get install -y apache2

b站韩博士的代码适用3B
sudo apt-get install -y mysql-server mysql-client
4B改为
sudo apt-get install -y mariadb-server-10.0 mariadb-client-10.0

访问验证localhost

检查状态
service apache2 status/start/stop/restart

active running绿色是正常。
2、安装PHP和PHPMYADMIN
sudo apt-get install -y php php7.3-mysql

sudo apt-get install -y phpmyadmin

php密码在之前配置过了。
sudo chmod 777 /var/www/html
sudo a2enmod rewrite
sudo ln -s /usr/share/phpmyadmin /var/www/html

访问验证 localhost/phpmyadmin。
报错了。
解决方法:
sudo apt-get install php-mbstring
service httpd restart
service apache2 restart

刷新。

同之前“安装PHP”。
3、为root设置登录
sudo mysql -u root -p

update mysql.user set plugin='mysql_native_password';

update mysql.user set password=PASSWORD("raspberry") where User='root';
root密码是raspberry

flush privileges;

exit退出。
(以上是之前安装过PHP,参照PHP那一节。)
该博客详细介绍了如何在Raspberry Pi设备上安装Apache web服务器、MariaDB数据库(替代了原来的MySQL)、PHP以及PHPMyAdmin。步骤包括使用sudo apt-get install命令安装各组件,配置MySQL(或MariaDB)的root用户密码,解决PHPMyAdmin的依赖问题,并通过访问localhost/phpmyadmin进行验证。此外,还提供了访问验证、服务状态检查以及为root用户设置登录密码的方法。
3947





