Why switch at all
Apache’s prefork model pairs each connection with a relatively heavy worker. Nginx delegates PHP execution to PHP-FPM and handles static files and slow clients with very little memory. On a small instance, that difference decides whether a traffic spike causes a slowdown or an out-of-memory kill.
The essential server block
You need one try_files rule for pretty permalinks, a location block that passes PHP to the socket, and a rule that denies access to dotfiles and to PHP inside uploads. Everything else is optional.
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Tune the pool, not just the server
Set PHP-FPM’s process manager to ondemand or dynamic with a conservative max_children based on available memory. A pool that spawns fifty workers on a 1 GB machine will swap itself to death regardless of which web server sits in front of it.
Finally, remember that .htaccess rules no longer apply. Recreate redirects, hotlink protection and access rules directly in the server block, and test every one of them after the switch.