Berikut konfigurasi WordPress pada Nginx yang telah terpasang pada komputer dengan sistem operasi Ubuntu 20.04 dengan PHP-FPM 7.4. Nama domain adalah blogkoe.web dan berlokasi di /var/www/blogkoe.
Struktur permalink yang digunakan adalah http://blogkoe.web/2021/10/22/judul-pos/
server {
listen 80;
#listen [::]:80 default ipv6only=on;
listen [::]:80;
root /var/www/blogkoe;
index index.php index.html index.htm index.nginx-debian.html;
server_name blogkoe.web;
client_max_body_size 20M;
access_log /var/log/nginx/blogkoe.access;
error_log /var/log/nginx/blogkoe.error error;
location / {
try_files $uri $uri/ /index.php?q=$1;
rewrite /wp-admin$ $scheme://$host$uri/index.php?q=$1 permanent;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_read_timeout 300;
fastcgi_param PHP_VALUE
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Semoga bermanfaat.
Leave a Reply