在LXD中使用Debian 11

为了使用PHP7.4,以下是在虚拟环境中安装Debian 11的方法。这将与Chromebook的Linux环境相同。

当安装完成并登录后,将会呈现如下情况。

$ ssh debian11.local
Linux debian11 6.2.0-33-generic #33-Ubuntu SMP PREEMPT_DYNAMIC Tue Sep  5 14:49:19 UTC 2023 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Sep 22 17:22:50 2023 from 10.112.67.1

uchida@debian11:~$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

操作系统的安装

lxc launch images:debian/11/amd64 debian11

设置root密码

lxc exec debian11  -- bash

登录

$ lxc console debian11
To detach from the console, press: <ctrl>+a q

debian11 login:

登录后的设置 de

创建用户

adduser --uid 1200 uchida
gpasswd -a uchida sudo

sshd 安装

sudo apt install ssh

安装 Avahi

sudo apt install avahi-daemon

如果Avahi可行,你可以按照以下方式登录。

ssh debian11.local

时区设置

sudo timedatectl set-timezone Asia/Tokyo

允许无密码执行sudo命令

sudo visudo
(省略)
%sudo ALL=(ALL:ALL) NOPASSWD:ALL
(省略)

PHP 的安装

sudo apt install php

安装所需的库。

sudo apt install php-mbstring php-mysql php-curl php-xml
sudo apt install php-fpm php-gd php-bz2 php-zip

确定

$ php -v
PHP 7.4.33 (cli) (built: Jun  9 2023 16:51:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

MariaDB的安装

sudo apt install mariadb-server

确定

$ sudo mariadb -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.5.19-MariaDB-0+deb11u2 Debian 11

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)]>