QQ图片20210823091857

(Nana 印象图 初版)

速览本文:

  • Docker 的安装
  • 数据库的安装
    • MariaDB
    • phpMyAdmin
  • nodejs 与 npm 的安装

Docker 的介绍与安装

What is Docker?

Docker takes away repetitive, mundane configuration tasks and is used throughout the development lifecycle for fast, easy and portable application development - desktop and cloud.

简而言之,就是打包好的应用,可以创建Docker容器来托管一系列应用.

安装

(Option 1) 使用官方安装脚本自动安装即可

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

(Option 2) 也可使用国内 daocloud 一键安装:

curl -sSL https://get.daocloud.io/docker | sh

但是在这里 c7w ran into problems.

详情可以看这里. 针对 armhf ubuntu 20.04: https://github.com/docker/for-linux/issues/1035

如果一键安装成功,请略过此处.

想不到吧 爷去装arm64了 不伺候您armhf了 只不过是从头再来 停更一天

大家就当无事发生过,这里 Nana 已经变成 arm64 了.

(Option 3) 也可以使用 Tsinghua 源.

可以参考 https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/ 手动安装.

数据库安装与配置

MariaDB

什么是 MariaDB?

MariaDB Server is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source.

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。 开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

Reference:

安装

sudo apt install mariadb-server

查看字符集

  • sudo mysql 进入控制台
 ubuntu@ubuntu > /etc/mysql > sudo mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 52
Server version: 10.3.31-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
  • show variables like "%character%";show variables like "%collation%"; 查看当前字符集
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.004 sec)

+----------------------+--------------------+
| Variable_name        | Value              |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
| collation_database   | utf8mb4_general_ci |
| collation_server     | utf8mb4_general_ci |
+----------------------+--------------------+
3 rows in set (0.003 sec)

这里已经是 utf8mb4 了,无须再更多配置.

安全性配置

sudo mysql_secure_installation 进行安全性配置.

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):
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
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
 ... 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
 - 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!

新建管理员用户

sudo mysql 进入控制台.

  • CREATE USER '<USERNAME>'@'%' IDENTIFIED BY '<YOUR PASSWORD>'; 创建用户
  • GRANT ALL PRIVILEGES ON *.* TO '<USERNAME>'@'%' WITH GRANT OPTION; 给予管理员权限

phpMyAdmin

安装

sudo apt install phpmyadmin

在询问是否需要帮助创建数据库时,选择取消.

在询问选择哪个软件作为管理 phpmyadmin server 的工具时,选择 apache2.

更改配置

  • 把 phpmyadmin 提供的默认的 apache2 配置文件移动到 apache2 目录下:

sudo mv /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled

  • 然后更改 apache2 监听的端口:

sudo vi /etc/apache2/ports.conf

把 80 端口改为没有被占用的端口.

image-20210825202754563

Node 的安装

我们直接使用已完成编译的包.

  • 先下载安装文件 wget https://nodejs.org/dist/v14.17.5/node-v14.17.5-linux-arm64.tar.xz

  • 解压 tar xf node-v14.17.5-linux-arm64.tar.xz

  • 进入目录 cd node-v14.17.5-linux-arm64/
  • 执行 node 查看版本 ./bin/node -v

这里 c7w 强迫症,还去搜索了这个文件应该放哪里比较好.

有时候需要配置ubuntu安装的软件,一般安装软件都是使用apt-get install。那么安装完后,软件的安装目录在哪里呢,可执行文件又放在哪里呢。

A、下载的软件的存放位置:/var/cache/apt/archives

B、安装后软件的默认位置:/usr/share

C、可执行文件位置:/usr/bin

D、配置文件位置:/etc

E、lib文件位置:/usr/lib

Reference:

  • 移动文件: sudo mv node-v14.17.5-linux-arm64 /usr/share
  • 建立软链接
ubuntu@ubuntu  /usr/bin  sudo ln -s /usr/share/node-v14.17.5-linux-arm64/bin/npm /usr/local/bin
 ubuntu@ubuntu  /usr/bin  sudo ln -s /usr/share/node-v14.17.5-linux-arm64/bin/node /usr/local/bin
 ubuntu@ubuntu  /usr/bin  node
Welcome to Node.js v14.17.5.
Type ".help" for more information.
>