I run my wordpress application on a local server, I write my content in this sandboxed server and then convert my website into html files and server it from s3 bucket as a static site. I helps me keep my server costs low and also keeps my website secure from unwanted attacks. I have multiple sites hosted within single nginx server and they are hosted a subdirectories. The below configuration helps me achieve that
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location /muthu {
try_files $uri $uri/ /muthu/index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(/muthu)(/.*)$;
}
}
My website folder is present in the /var/www/
directory