在安装之前最好确保完全卸载旧版本或者保证二者不会冲突。

将会安装

  • Mariadb 10.5
  • Java 8
  • nginx (latest)

  1. 装完系统后如果没有配置时区:
export TZ='Asia/Shanghai'
echo -n "$TZ" > /etc/timezone
  1. 如果觉得默认源下载太慢可以更换源,这里使用 TUNA 源
sed -ri 's/(archive|security)\.ubuntu\.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
apt-get update
  1. 安装 Java 和依赖程序
apt-get install -y openjdk-8-jre curl gnupg2 ca-certificates lsb-release
  1. 安装第三方程序签名和发布源
apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
echo "deb [arch=amd64,arm64,ppc64el] https://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.5/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/mariadb.list
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor > /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list
  1. 更新源并安装软件
apt-get update && apt-get install -y mariadb-server nginx
  1. 启动服务
# nginx
systemctl enable --now nginx
# 如果在 docker 环境中,默认未安装 systemd,使用下面的命令启动
#/etc/init.d/nginx start

# mariadb
systemctl enable --now mariadb
# 如果在 docker 环境中,默认未安装 systemd,使用下面的命令启动
#/etc/init.d/mariadb start
  1. 配置 Mariadb 使用密码访问(默认使用 unix socket)
echo "UPDATE mysql.global_priv SET priv=json_set(priv, '$.plugin', 'mysql_native_password', '$.authentication_string', PASSWORD('123456')) WHERE User='root';" | mysql -u root
echo "FLUSH PRIVILEGES;" | mysql -u root

完整脚本如下

export TZ='Asia/Shanghai'
echo -n "$TZ" > /etc/timezone
sed -ri 's/(archive|security)\.ubuntu\.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
apt-get update && apt-get install -y openjdk-8-jre curl gnupg2 ca-certificates lsb-release
apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
echo "deb [arch=amd64,arm64,ppc64el] https://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.5/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/mariadb.list
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor > /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list
apt-get update && apt-get install -y mariadb-server nginx
/etc/init.d/mariadb start
echo "UPDATE mysql.global_priv SET priv=json_set(priv, '$.plugin', 'mysql_native_password', '$.authentication_string', PASSWORD('123456')) WHERE User='root';" | mysql -u root
echo "FLUSH PRIVILEGES;" | mysql -u root
/etc/init.d/nginx start

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据