If your Plesk server is configured to run Nginx in from of Apache then you may encounter “504 Gateway Timeout” errors when executing long running PHP pages. Nginx is acting as a reverse proxy for Apache. The “proxy_read_timeout” configuration setting in Nginx controls how long Nginx will wait for Apache to return a response. The default is 60 seconds which may be too short if you have a script that takes several minutes to run. To increase this timeout, just edit /etc/nginx/nginx.conf and add the highlighted line:
Don’t forget to restart Nginx after making the change.