Page cover

LEMP Platform

Linux-Nginx-MySQL-PHP ဆာဗာအမိျုးအစားကို တပ်ဆင်ခြင်း နှင့် အသုံးပြုခြင်း (သို့) Nginx Web Server အမျိုးအစားတစ်ခု တပ်ဆင်အသုံးပြုခြင်း

On Ubuntu Server

အောက်ပါ ကြိုတင်လုပ်ဆောင်ရန်များကို ပြီးစီးထားရမည်။

Ubuntu 16.04 initial server setup

Reference:

How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04

Step 1 — Setting Up New Document Root Directories

sudo mkdir -p /var/www/example.com/html

sudo chown -R $USER:$USER /var/www/example.com/html

sudo chmod -R 755 /var/www

Step 2 — Creating Sample Pages for Each Site

Upload files as requires ...

Step 3 — Creating Server Block Files for Each Domain

ပထမဦးဆုံး Server Block File ပြုလုပ်ရန် Default ပါလာသော ဖိုင်ကို ကော်ပီကူးပြီး ပြုလုပ်နိုင်သည် -

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example.com

နောက်ထပ် Server Block Files များ ပြုလုပ်ရန် -

sudo nano /etc/nginx/sites-available/example.com

အောက်ပါအတိုင်း ပြင်ဆင်ပေးမည် -

server {

listen 80;

listen [::]:80;

root /var/www/example.com/html;

index index.html index.htm index.nginx-debian.html;

server_name example.com www.example.com;

location / {

try_files $uri $uri/ =404;

}

}

အကယ်၍ PHP application or WordPress ဖြစ်မည်ဆိုလျှင် -

server {

listen 80;

listen [::]:80;

root /var/www/example.com/html;

index index.html index.htm index.nginx-debian.html;

server_name example.com www.example.com;

location / {

#try_files $uri $uri/ =404;

# For wordpress

try_files $uri $uri/ /index.php?$args;

}

location ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

}

location ~ /\.ht {

deny all;

}

}

Step 4 — Enabling your Server Blocks and Restart Nginx

Nginx ဆာဗာဖြစ်သည့်အတွက် symbolic links ချိတ်ပေးရမည် -

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/

ပထမဦးဆုံး ပြုလုပ်ခြင်းဖြစ်ပါက Nginx Server Configuration ကို အောက်ပါအတိုင်း အနည်းငယ် ပြင်ဆင်ပေးရမည် -

sudo nano /etc/nginx/nginx.conf

http {

. . .

server_names_hash_bucket_size 64;

. . .

}

Nginx configuration များ မှန်/မမှန် ကို စစ်ကြည့်မည် -

sudo nginx -t

အားလုံးအဆင်ပြေလျှင် Nginx ကို Restart ပြုလုပ်ခြင်းဖြင့် Configuration များနှင့် Server Blocks များ Update ပြုလုပ်ပေးမည် -

sudo systemctl restart nginx

Secure Nginx with Let's Encrypt

Reference:

How to Secure Nginx with Let’s Encrypt

sudo certbot --nginx -d example.com -d www.example.com

Verifying Certbot Auto-Renewal

sudo certbot renew --dry-run

Last updated

Was this helpful?