在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
sudo mv composer.phar /usr/local/bin/composer
sudo apt install mariadb-server
/etc/nginx/sites-available/example-app
,并添加以下内容:server {
listen 80;
listen [::]:80;
server_name example-app.local;
root /path/to/your/laravel/project/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 ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
sudo ln -s /etc/nginx/sites-available/example-app /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
确保Laravel项目的 storage
和 bootstrap/cache
目录具有适当的读写权限:
sudo chown -R www-data:www-data /path/to/your/laravel/project/storage
sudo chown -R www-data:www-data /path/to/your/laravel/project/bootstrap/cache
sudo chmod -R 775 /path/to/your/laravel/project/storage
sudo chmod -R 775 /path/to/your/laravel/project/bootstrap/cache
完成以上步骤后,您应该能够在Debian上成功运行Laravel。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>