♞树莓派之安装LAMP

#使用镜像
2019-09-26-raspbian-buster-lite.img
#系统信息
sudo uname -a
#Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
安装Apache2
sudo apt-get install apache2
#安装PHP7.3
sudo apt install -y -t buster php7.3-fpm php7.3-curl php7.3-gd php7.3-intl php7.3-mbstring php7.3-mysql php7.3-imap php7.3-opcache php7.3-sqlite3 php7.3-xml php7.3-xmlrpc php7.3-zip
#Apache关联PHP7.3
sudo apt install libapache2-mod-php7.3
#安装MariaDB
sudo apt install mariadb-server

#MariaDB初始化命令
mysql_secure_installation

#安装phpmyadmin
sudo apt install phpmyadmin
#在网站根目录做文件映射
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
cd /etc/apache2/mods-enabled
sudo nano dir.conf
#在DirectoryIndex后面调整或添加新的主页

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
  
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
  
Enter current password for root (enter for none): #-->输入root密码,直接回车
OK, successfully used password, moving on...
  
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
  
Set root password? [Y/n] y    #-->设置root密码   
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
  
  
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
  
Remove anonymous users? [Y/n] y    #-->删除匿名用户
 ... Success!
  
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
  
Disallow root login remotely? [Y/n] y    #-->禁止root远程登录
 ... Success!
  
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
  
Remove test database and access to it? [Y/n] y    #-->删除test数据库和对此数据库的访问权限
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
  
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
  
Reload privilege tables now? [Y/n] y    #-->立即刷新权限
 ... Success!
  
Cleaning up...
  
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
  
Thanks for using MariaDB!
#-->终端下输入mysql -uroot -p 进入数据库
#显示所有表
show tables;
#使用mysql数据库
use mysql;
#显示user表的Host、User字段
select Host,User from user;

#创建一个新用户
CREATE USER '用户名'@'%' IDENTIFIED BY '用户密码';
#赋予所有权限
GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' WITH GRANT OPTION;
##简化方案创建用户与赋予权限在一起执行
# GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '用户密码' WITH GRANT OPTION;
##

#刷新权限
flush privileges;

#-->终端下输入service mariadb restart 重启数据库
sudo nano /etc/mysql/my.cnf
#禁用掉bind_address属性,因为这里绑定的127.0.0.1是本地回旋地址。

 

阅读剩余
THE END