Ubuntu 部署 Laravel 项目步骤
一 准备与安装基础环境
二 创建或拉取项目并安装依赖
三 配置数据库
四 配置 Nginx 站点
server { listen 80; server_name yourdomain.com www.yourdomain.com; root /var/www/yourproject/public; index index.php index.html;
location / { try_files $uri $uri/ /index.php?$query_string; }
location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.1-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
location ~ /.ht { deny all; } }
五 文件权限与目录可写
六 生产环境优化与可选组件