This article contains information/examples using root/sudo/admin users. If you require sudo/admin access, you must upgrade to a Dedicated server.
PHP 5.6 is the only version available with VPS machines purchased before March 2020.
PHP 7.2, 7.3, and 7.4 are available on VPS machines purchased after March 2020. Older versions are not supported.
PHP processes per user
For security purposes, it's generally advised to assign a single user to each domain. This way if that user is compromised, no other sites are affected. However, when running Nginx, it's recommended that you consolidate your domains under a single username. This is for performance reasons.
Nginx uses a set number of PHP processes when starting up. This happens for each user, and the same number are started regardless of how many domains are hosted under the user.
However, if you have 10 domains spread across 10 separate FTP users, you'll get 10x as many PHP processes as you would otherwise get with a single user.
Also, keep in mind that the number of PHP processes that spawn per user is automatically scaled with the amount of memory your VPS is set to use.
Limiting the amount of processes spawned per domain
Unlike Apache or Lighttpd, Nginx does not automatically spawn FCGI processes. You must start them separately. PHP5 auto-spawns as many as you set in the PHP_FCGI_CHILDREN environment variable.
View the following article for details:
The PHP_FCGI_CHILDREN variable affects how many PHP pages can be processed simultaneously. The lower the value, the less memory used. But if you're getting a lot of traffic this slows down your response time. This value defaults to 9 on DreamHost Nginx servers.
Globally on a Dedicated server
- Using an admin user on a Dedicated server, navigate to the following directory:
- Use the sudo command to edit this file. You'll see the following lines:
PHP_FCGI_CHILDREN is the number of desired processes per domain.
- Navigate to your user's $HOME directory.
[server]$ cd ~
- Create a .php-launcher file with the following contents:
#!/bin/sh export PHP_FCGI_CHILDREN=9 exec /dh/cgi-system/php5.cgi $*
- Make the script executable:
[server]$ chmod a+x .php-launcher