sudo apt-get install mysql-server
# 检查安装是否成功
mysql --version
systemctl status mysql.service
# root 密码默认为空,但是只有root用户能进
sudo mysql
# 安全提升:the removal of test users, test databases and permission for remote login by a root user.
# sudo mysql_secure_installation
# 修改 mysql root 密码
# mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
# mysql> FLUSH PRIVILEGES;
1
2
3
4
5
6
7
# 创建数据库 moodle
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# 添加 app 的数据库用户
mysql> CREATE USER moodleuser@'192.168.%.%' IDENTIFIED BY 'moodle';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@'192.168.%.%';
mysql> FLUSH PRIVILEGES;
安装 Apache2
1
2
3
4
sudo apt install apache2
sudo ufw app list
sudo ufw app info "Apache Full"
sudo ufw allow in "Apache Full"
All aliases in Apache 2.4 have to be configured in the /etc/apache2/mods-enabled/alias.conf file.
Apache >= 2.4
1
2
3
4
5
6
7
8
# moodle
Alias /moodle/ "/opt/moodle/moodle-310/"
<Directory "/opt/moodle/moodle-310">
Options FollowSymlinks
AllowOverride None
Require all granted
</Directory>
Apache 2.2
1
2
3
4
5
6
Alias /moodle "/opt/server/moodle/moodle-310"
<Directory "/opt/server/moodle/moodle-310">
AllowOverride None
Order allow,deny
Allow from all
</Directory>