Raspberry PI 5 Deployment of Nginx and PHP


sudo apt update
sudo apt install nginx php-fpm php-mysql -y

sudo nano /etc/nginx/sites-available/default

server {
    listen 80;
    root /var/www/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    # 啟用 PHP 處理
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
    }
}
sudo nginx -t && sudo systemctl restart nginx
sudo usermod -a -G www-data $USER
sudo chown -R -f www-data:www-data /var/www/html
sudo chmod -R 775 /var/www/html

reboot

發佈留言