ServerAvatarDocs
Applications

PHP settings

Choose an application's PHP version, set its memory, upload and time limits, tune its PHP workers, harden it, and import a v7 PHP config.

PHP settings shows and changes how one PHP application runs: the PHP version, the memory and upload limits, how many PHP workers it has and which PHP functions it may use. Open an application, then select PHP settings in its sidebar, under Settings.

Only PHP applications have this screen: "PHP settings are only available for applications that run PHP." A Node.js, static or Docker application does not.

The PHP settings screen: the In effect now strip, the tabs Basic settings, Security and Advanced, the PHP version, Memory per request and PHP workers fields, and the Import v7 config button

The strip at the top, In effect now, shows the PHP version, Memory, Uploads, Time limit and Runs as (the system user). A value you have changed but not saved shows "not saved yet".

The settings are in three tabs. Nothing applies until you save: "Saving reloads PHP for this site."

Change the PHP version and the basic limits

  1. Open the Basic settings tab.
  2. Under Runtime, pick the PHP version. "Only versions installed on this server are listed. Check that your application supports the one you pick." Install another version on the server's PHP page first.
  3. Set Memory per request (memory_limit): "The most memory one page load may use. Raise it if you see "Allowed memory size exhausted"."
  4. Set PHP workers (pm.max_children): "How many requests PHP handles at the same time. Each one can use up to the memory per request." Pick a Starting points button, Low traffic, Balanced or High traffic, or choose Custom… and type your own number. "Your own numbers. Pick a starting point to replace them."
  5. Under Uploads and time limits set:
    • Largest upload (upload_max_filesize): "The biggest file visitors can upload. The form submission limit is raised to match."
    • Time limit per request (max_execution_time, in seconds): "How long one request may run before PHP stops it."
    • Form fields per request (max_input_vars): "How many fields one form may send. Raise it for large menus or product forms."
  6. Select Save changes. You see "PHP settings saved." Discard throws away your unsaved changes. The bar counts them ("n unsaved changes").

A bar under the workers shows what the site could claim: "This site's PHP can use up to value." and "value of total still free on the server." Memory per request × PHP workers is the most the site's PHP can take, and the grey part is the other sites on the server. If the total is more than the server has, it turns red with Over committed: "All sites together can claim required, but this server has total." Lower the memory or the workers.

Move cron jobs to the new PHP version

When you change the version and some of the site's cron jobs still use another PHP, a dialog asks Move cron jobs to PHP version too? "Nothing has changed yet. Tick the ones to move." A job that follows the server default can stay on the default. Select Move n cron jobs, or Not now. You see "n cron jobs now run on PHP version." This needs Manage on Cron Jobs: otherwise "Your role does not include Cronjob with Manage access. Ask an administrator to grant it."

Security

  1. Open the Security tab.

    The Security tab: Keep PHP inside the site's folders with its always-allowed folders, Let PHP open web addresses like files, and the list of blocked functions

  2. Keep PHP inside the site's folders (open_basedir): "PHP can only open files in the folders below, so a hacked site can't read other sites' files." Turned off: "PHP can open files anywhere the site's user can." The folders that are Always allowed are listed. Add more under Extra allowed folders, one per line.

  3. Let PHP open web addresses like files (allow_url_fopen): "Some plugins need it to fetch updates or remote images. Turning it off blocks a common way of loading harmful code."

  4. Blocked functions (disable_functions): "PHP functions the site can't use. Blocking the ones that run server commands limits what a hacked site can do." Remove a function with its × (Unblock name), or type a name under Function to block and select Block. Quick choices replace the whole list with one of the server's sets. "No functions are blocked." shows when the list is empty. A wrong name says "Not a function name: names".

  5. Select Save changes.

Advanced

Open the Advanced tab. It opens with a warning: "Most sites never need these. Change them only when your application's documentation asks you to."

The Advanced tab: How workers start, Requests before a worker restarts, Stop idle workers after, the form and session limits, Timezone and the file to run before every request

Workers

  • How workers start (pm): On demand starts workers only when needed, Dynamic keeps a few ready, Always on keeps them all running.
  • Requests before a worker restarts (pm.max_requests): "Restarting workers now and then frees memory that leaks. 0 never restarts them."
  • With Dynamic: Workers at start, Fewest idle workers, Most idle workers and Workers started at once. With On demand: Stop idle workers after (seconds).

Requests and sessions

  • Largest form submission (post_max_size): "The most data one form submission may send, uploads included."
  • Time to receive a request (max_input_time, seconds): "How long PHP waits to receive a request's data, such as a slow upload."
  • Session lifetime (seconds) (session.gc_maxlifetime): "How long an inactive login session is kept."
  • Timezone (date.timezone): "Leave empty to use the server's."
  • Run a file before every request (auto_prepend_file): "A PHP file run before every page, for example a firewall or a debugging tool."
  • Extra PHP settings (additional_directives): "Any other PHP setting, one per line, as name = value."

Each field with a changed value offers Reset to default.

Give a site its own PHP pool

A site that shares the server's PHP pool shows This site shares the server's PHP pool and Runs as user. "Its PHP runs alongside other sites, so its limits and security settings can't be set." Only the PHP version can be changed.

  1. Select Isolate.
  2. Read Give this site its own PHP pool? "PHP-FPM is reloaded once. The site then runs as its own system user." Confirm. You see "The site now has its own PHP pool."

A pool of its own unlocks the memory, upload and time limits, its own PHP workers, the folder and function restrictions and the extra PHP settings.

Import a v7 config

If the site had extra PHP-FPM lines on ServerAvatar v7, convert them into settings.

  1. Select Import v7 config.

    The Import a v7 PHP config dialog with a text box for the extra PHP-FPM configuration from v7 and the Convert button

  2. Paste the lines into Extra PHP-FPM configuration from v7 (up to 20,000 characters) and select Convert. Nothing is saved yet.

  3. Read the summary: the Settings that change with Now and From v7, and Not imported for lines that cannot be used.

  4. Select Fill the form. The values are put in the form: "Filled from v7. Review the settings and press Save." Nothing is saved until you select Save changes. If some values do not pass the checks, you can still fill the form and fix them there.

Limits

  • The server checks every value and its range. The shape Central accepts: text values up to 255 characters, Extra allowed folders and Blocked functions up to 2,000, Extra PHP settings up to 4,000. Memory and size values are written like 256M.
  • The v7 import takes at most 20,000 characters and 30 conversions per minute.
  • An edit made by hand in the pool file shows "The pool file was edited by hand. Saving replaces those edits."

Who can do this

  • Seeing the screen needs View on PHP Settings (application.php). Everything that changes needs Manage on PHP Settings: with view only the fields are read-only. A role without view sees "Your role can't view this application's PHP settings."
  • Moving cron jobs to a new PHP version also needs Manage on Cron Jobs (server.cronjob).
  • PHP Settings can be given in a server share.

Common errors

  • The server didn't accept the change. The server refused a value. Its own message is shown. Fix the value and save again.
  • We couldn't load the PHP settings from the server. Select Retry.
  • The server isn't ready yet. The server is offline or still being set up.
  • Your role can't change PHP settings. Ask an owner for Manage access.

On this page