部署
1. 依赖服务
- MySQL(必需)
- Redis(7.x,必需)
- Nginx + PHP-FPM
2. 发布
bash
composer install --no-dev --optimize-autoloader- 站点根目录指向:
public/ runtime/目录确保可写- 生产环境请关闭
APP_DEBUG - 建议上传目录:
/opt/youlai-think
3. Nginx / PHP-FPM
最小配置示例(按实际 PHP-FPM 版本修改 socket):
nginx
server {
listen 80;
server_name your_domain.com;
root /opt/youlai-think/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}要点:
- Nginx 反向代理到 PHP-FPM
- Rewrite 指向
public/index.php
4. 验证
- Swagger:
http://<host>/swagger
