优化项目结构
This commit is contained in:
@@ -34,7 +34,7 @@ class UploadController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$filename = uniqid() . '.' . $ext;
|
$filename = uniqid() . '.' . $ext;
|
||||||
$uploadDir = __DIR__ . '/../../uploads/';
|
$uploadDir = __DIR__ . '/../../public/uploads/';
|
||||||
$filepath = $uploadDir . $filename;
|
$filepath = $uploadDir . $filename;
|
||||||
|
|
||||||
if (!move_uploaded_file($file['tmp_name'], $filepath)) {
|
if (!move_uploaded_file($file['tmp_name'], $filepath)) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ chown -R www:www .
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
chown -R www-data:www-data /path/to/ai-chat
|
chown -R www-data:www-data /path/to/ai-chat
|
||||||
chmod 755 /path/to/ai-chat/uploads
|
chmod 755 /path/to/ai-chat/public/uploads
|
||||||
chmod 755 /path/to/ai-chat/config
|
chmod 755 /path/to/ai-chat/config
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -56,13 +56,13 @@ location /api/chat/completions {
|
|||||||
fastcgi_read_timeout 300s;
|
fastcgi_read_timeout 300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 4. 静态资源缓存
|
# 4. 静态资源缓存(assets/ 和 uploads/ 已在 public 目录下,无需 alias)
|
||||||
location /assets/ {
|
location /assets/ {
|
||||||
expires 30d;
|
expires 30d;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
}
|
}
|
||||||
|
|
||||||
# 5. 上传文件访问
|
# 5. 上传文件缓存
|
||||||
location /uploads/ {
|
location /uploads/ {
|
||||||
expires 7d;
|
expires 7d;
|
||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
|
|||||||
@@ -71,16 +71,14 @@ server {
|
|||||||
fastcgi_read_timeout 300s;
|
fastcgi_read_timeout 300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 静态资源直接服务
|
# 静态资源缓存
|
||||||
location /assets/ {
|
location /assets/ {
|
||||||
alias /path/to/ai-chat/assets/;
|
|
||||||
expires 30d;
|
expires 30d;
|
||||||
add_header Cache-Control "public, immutable";
|
add_header Cache-Control "public, immutable";
|
||||||
}
|
}
|
||||||
|
|
||||||
# 上传文件直接服务
|
# 上传文件缓存
|
||||||
location /uploads/ {
|
location /uploads/ {
|
||||||
alias /path/to/ai-chat/uploads/;
|
|
||||||
expires 7d;
|
expires 7d;
|
||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ $envChecks = json_encode([
|
|||||||
['name' => 'PHP 版本 >= 8.0', 'pass' => version_compare(PHP_VERSION, '8.0.0', '>=')],
|
['name' => 'PHP 版本 >= 8.0', 'pass' => version_compare(PHP_VERSION, '8.0.0', '>=')],
|
||||||
['name' => 'PDO 扩展', 'pass' => extension_loaded('pdo')],
|
['name' => 'PDO 扩展', 'pass' => extension_loaded('pdo')],
|
||||||
['name' => 'cURL 扩展', 'pass' => extension_loaded('curl')],
|
['name' => 'cURL 扩展', 'pass' => extension_loaded('curl')],
|
||||||
['name' => 'uploads/ 目录可写', 'pass' => is_writable(__DIR__ . '/../uploads')],
|
['name' => 'uploads/ 目录可写', 'pass' => is_writable(__DIR__ . '/uploads')],
|
||||||
['name' => 'config/ 目录可写', 'pass' => is_writable(__DIR__ . '/../config')],
|
['name' => 'config/ 目录可写', 'pass' => is_writable(__DIR__ . '/../config')],
|
||||||
]);
|
]);
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user