# 实验环境
- 操作系统:Debian 12
- Nginx:1.22.1
- Php:8.2.20
- Php-fpm:php8.2-fpm
# 实验步骤
# 安装程序包与依赖
| |
| apt update |
| |
| |
| apt install nginx |
| apt install php php-fpm php-xml php-json php-curl php-mbstring |
# 配置 Nginx
| |
| nano /etc/php/8.2/fpm/pool.d/www.conf |
| |
| listen = /run/php/php8.2-fpm.sock |
| |
| nano /etc/nginx/conf.d/xxx.conf |
| |
| |
| location ~ \.php$ { |
| include snippets/fastcgi-php.conf; |
| fastcgi_pass unix:/run/php/php8.2-fpm.sock; |
| } |
# 修改时区
| |
| timedatectl |
| |
| Local time: Tue 2024-07-03 14:00:00 UTC |
| Universal time: Tue 2024-07-03 14:00:00 UTC |
| RTC time: Tue 2024-07-03 14:00:00 |
| Time zone: UTC (UTC, +0000) |
| System clock synchronized: yes |
| NTP service: active |
| RTC in local TZ: no |
| |
| |
| timedatectl set-timezone Asia/Shanghai |
| |
| timedatectl |
| |
| Local time: Tue 2024-07-03 22:00:00 CST |
| Universal time: Tue 2024-07-03 14:00:00 UTC |
| RTC time: Tue 2024-07-03 14:00:00 |
| Time zone: Asia/Shanghai (CST, +0800) |
| System clock synchronized: yes |
| NTP service: active |
| RTC in local TZ: no |
| |
| |
| nano /etc/php/8.2/fpm/php.ini |
| |
| date.timezone = Asia/Shanghai |
# 重启服务
| service php8.2-fpm restart |
| service nginx restart |
# 调试步骤
| |
| tail -f /var/log/nginx/access.log |
| |
| tail -f /var/log/php8.2-fpm.log |
# 验收
编写任意 php 文件,比如说简单的有 index.php:
| <h1> |
| <span> Hello, this is test page </span> |
| </h1> |
或者 php 探针:
访问该 php 地址,得到正确的返回结果。完结,Move On!