版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

简介

本文内容基于基础的 Debian12 的镜像完成 Nginx+PHP+MySQL 的配置,各组件版本如下表

内容版本备注
操作系统Debian 12使用清华镜像源
Nginx1.29.3Nginx 官网源
MySQL8.4.7Oracle 官网源
PHP8.2操作系统源

配置操作系统镜像源

系统的安装可以参考 https://wiki.waringid.me/x/MYAYAQ 的内容。系统镜像源的配置如下

代码块
languageshell
sudo vim /etc/apt/sources.list.d/debian.sources

Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
Suites: bookworm bookworm-updates bookworm-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
# Types: deb-src
# URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
# Suites: bookworm bookworm-updates bookworm-backports
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: bookworm-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

# Types: deb-src
# URIs: https://security.debian.org/debian-securty
# Suites: bookworm-security
# Components: main contrib non-free non-free-firmware
# Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

完成配置后执行更新操作

配置 Nginx

Nginx 采用官网源更新至最新的版本

代码块
languageshell
sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor     | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx"     | sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt update
sudo apt install nginx -y
nginx -v
sudo cat /etc/apt/sources.list.d/nginx.list
代码块
languagetext
deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/mainline/debian bookworm nginx
代码块
languagenginx
user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log notice;
pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
    include /etc/nginx/conf.d/*.conf;
}

配置 Mysql

Mysql 采用官网源更新至 8.4.2 版本。

原计划使用清华源的配置完成数据库的安装,但是更新过程中一直报证书错误,通过其它的方法没法解决该问题。采用官网的源完成更新。

代码块
languageshell
wget https://dev.mysql.com/downloads/repo/apt/mysql-apt-config_0.8.36-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.36-1_all.deb
sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation
sudo cat /etc/apt/sources.list.d/mysql.list
代码块
languagetext
deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-apt-config
deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-8.4-lts
deb [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-tools
deb-src [signed-by=/usr/share/keyrings/mysql-apt-config.gpg] http://repo.mysql.com/apt/debian/ bookworm mysql-8.4-lts

配置 php

PHP 采用系统自带的源安装

代码块
languageshell
sudo apt-get install php php-mysql php-cli php-fpm graphviz php-xml php-gd php-zip php-curl php-mbstring php-json php-apcu

需要配置 Nginx 和 PHP 组合,需要调整对应的权限组。默认情况下 Nginx 的启动用户是 Nginx,PHP-FPM 的启动用户是 www-data。两者需要设置一致,否则后续启动访问时会报错。



目录