Sunday, October 26, 2025

ติดตั้ง Nginx + PHP-FPM ใน Debian 12 in WSL

Ref
https://share.google/aimode/jYqPzJuf6u3AMYLBp
  • อัพเดทและอัพเกรด

sudo apt update && sudo apt upgrade -y

  • ติดตั้ง cer repo

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https -y

  • เพิ่ม php repo

sudo add-apt-repository ppa:ondrej/php

  • อัพเดท repo

sudo apt update

  •   ติดตั้งสิ่งที่ต้องมี

sudo apt install nginx php8.3-fpm php8.3 php8.3-curl php8.3-xml php8.3-ziz php8.3-mbstring php8.3-mysql php8.3-gd -y

sudo apt install php8.2-sqlite3 php8.2-pdo-sqlite php8.2-pgsql

sudo apt install composer 

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

  • แก้ไขคอนฟิกเกี่ยวกับ nginx+php ประมาณนี้

server {

    listen 80;

    server_name your_domain_or_ip; # Replace with your domain or IP address

    root /var/www/html; # Or your web root directory


    index index.php index.html index.htm;


    location / {

        try_files $uri $uri/ =404;

    }


    location ~ \.php$ {

        include snippets/fastcgi-php.conf;

        fastcgi_pass unix:/run/php/php8.3-fpm.sock;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include fastcgi_params;

    }

}

  • ตรวจสอบคอนฟิก และ รีสตาร์ท

sudo nginx -t

sudo systemctl restart nginx

sudo systemctl restart php8.3-fpm

เพิ่มเติม

  • สำหรับ Laravel 12.* แนะนำลง php extension เหล่านี้ให้เรียบร้อย phpX.X-curl, phpX.X-xml, phpX.X-zip สำหรับใช้  composer

No comments:

Post a Comment

Popular Posts