nginx php-fpm


apt install nginx-full php7.4-fpm

(php7-mysql php-gd additional for wordpress)

nano /etc/php7/fpm/php.ini
upload_max_filesize = 64M
post_max_size = 64M

sample config http for wordpress site.

nginx webroot directory is /var/www/kampot

file name kampot.conf in /etc/nginx/conf.d

file is additional to basic nginx config (file name and path added in nginx.config)

running with php7.4-fpm

server { listen 80; charset utf-8; server_tokens off; server_name; root /var/www/kampot;autoindex off;

default_type application/octet-stream;
sendfile on;
keepalive_timeout 3;

index index.php index.html index.htm;
client_max_body_size 20M;

rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ “/index.php?xml_sitemap=params=$2” last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ “/index.php?xml_sitemap=params=$2;zip=true” last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ “/index.php?xml_sitemap=params=$2;html=true” last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ “/index.php?xml_sitemap=params=$2;html=true;zip=true” last;

location / { try_files $uri $uri/ /index.php?$args; }
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; }

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { allow all; log_not_found off; access_log off; }
location ~ /\. { deny all; }
location ~* /(?:uploads|files)/.*\.php$ { deny all; }

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/kampot$fastcgi_script_name;
include fastcgi_params;
resolver valid=86400; resolver_timeout 10; access_log off; }