在Debian上安裝Laravel時,首先需要選擇一個合適的Debian版本。以下是關于Debian版本選擇以及安裝Laravel的簡要指南:
sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo apt install php php-cli php-common php-json php-gmp php-fpm php-xmlrpc php-bcmath php-imagick php-curl php-zip php-gd php-mysql php-xml php-mbstring php-xmlrpc php-intl php-sqlite3
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer create-project --prefer-dist laravel/laravel example-app
在/etc/nginx/conf.d
目錄下創建一個example-app.conf
文件,并添加以下內容:
server {
listen 80;
listen [::]:80;
server_name example-app.local;
root /home/david/example-app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
sudo systemctl restart nginx
以上步驟將在Debian系統上安裝Laravel環境。請注意,這里的示例使用的是Debian 12,但大多數步驟也適用于其他穩定版本的Debian。
希望以上信息能幫助你在Debian上選擇合適的Laravel版本并進行安裝。