Debian 通过 APT 安装 PHP

用 WSL Debian 12 安装 php 做开发,apt 的 PHP 版本足够新,安装非常方便。
如果 Debian 版本比较老,建议参考这里通过源码编译安装PHP

1
2
sudo apt install php php-dev php-gd php-curl php-mysql \
php-mbstring php-redis php-xdebug php-intl php-zip

安装 swoole

1
sudo pecl install swoole

修改配置

1
sudo vim /etc/php/8.2/cli/php.ini

加入:

1
extension=swoole.so

Debian 通过 APT 安装 MariaDB

在开发环境完全可以用 MariaDB 代替 MySQL,而且安装更方便。

1
2
3
4
5
6
7
8
9
10
11
# 更新索引包
sudo apt update
# 安装 MariaDB 软件包
sudo apt install mariadb-server
# 配置 MariaDB
sudo mysql_secure_installation
# 启动服务
sudo service mariadb start

# 查看服务状态
sudo service --status-all

服务状态显示例如:

1
2
3
4
5
6
7
8
9
[ + ]  cron
[ - ] hwclock.sh
[ + ] kmod
[ + ] mariadb
[ + ] networking
[ + ] procps
[ - ] rsync
[ - ] sudo
[ + ] udev
  • [ + ] 为已启动
  • [ - ] 为未启动

配置文件位置:

1
/etc/mysql/debian.cnf

Debian 12 设置使用清华镜像源

Debian 官方源网速太慢,换成国内源必不可少。

1、安装 apt https 支持

1
sudo apt install apt-transport-https ca-certificates

2、修改源

先备份 /etc/apt/sources.list,然后把其内容替换为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

备注