Ubuntu 20 ติดตั้ง Nginx, PHP

เริ่มมาก็ตามนี้เลยนะ

 

เริ่มเช็ค firewall

sudo ufw status

โดยจะ disable ไปก็ได้ในการ dev

sudo ufw disable

จากนั้นลง nginx

sudo apt update
sudo apt install nginx

 

จากนั้นติดตั้ง php

apt install php php-fpm php-mysql php-mbstring

 

จากนั้นไปที่อยู่ไฟล์ของ nginx แล้วเช็คตามนี้

 

vi /etc/nginx/sites-available/default

 

 

server {
    listen 80;
    server_name your_domain www.your_domain;
    root /var/www/your_domain;

    index index.html index.htm index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }

}

จากนั้นลอง start service 
systemctl start php7.4-fpm.service
systemctl start nginx
แล้วทำ start up
systemctl enable php7.4-fpm.service
systemctl enable nginx
โดยที่อยู่เว็บจะอยู่ที่ /var/www/html/

จากนั้น ให้ลองทำ phpinfo ดู เพื่อเช็คว่า ใช้ php ได้ไหม

 

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องที่ต้องการถูกทำเครื่องหมาย *