Make global PHP changes on a Dedicated server

 

Overview

You can apply global PHP changes to your Dedicated server by editing a single php.ini file for the entire server, rather than configuring each site individually. You can also set PHP options on a per-user basis using a phprc file. See the php.ini overview article for more information.

Background

Every installation of PHP comes with default settings which are usually fine for most websites. Occasionally, the needs of a website make it necessary to adjust these PHP settings. For example, your site may need to upload files larger than the current PHP upload limit allows. In that case, you would need to create a php.ini (phprc) file and update this value. If you have a Dedicated Server it’s possible to set a single phprc file for the entire server, rather than set them up individually for each site.

If you have a custom phprc file set up under your user, it will override the global php.ini file for that specific user, for the version of PHP for which the custom phprc file was created.

How do I enable global PHP changes?

The following sections describe how to make global changes and other related updates on your dedicated server.

How do I make PHP configuration changes?

Prerequisites

If you intend to make Global changes to your PHP configuration, you must UN-check the DreamHost Managed checkbox in your panel. Otherwise, your custom settings will be overwritten by the server next time a config is run:

  1. Navigate to the Servers & Usage page.
  2. To the right of the server, click the Configure button.
  3. On the next page, UN-check DreamHost Managed.
  4. Click Save ds#### settings... at the bottom to save.
  1. Log into your server via SSH using your admin user. You can create an admin user on the SFTP Users & Files page.
  2. Once you log into your server, navigate to the directory for the version of PHP you wish to edit:
    PHP 8.3

    [server]$ cd /etc/php83

    PHP 8.4

    [server]$ cd /etc/php84

    PHP 8.5

    [server]$ cd /etc/php85

    Once you are in that directory, you’ll see the php.ini file.

  3. Run the following command to edit it:

    [server]$ sudo nano php.ini
  4. When finished editing, close the file and return to your shell.
  5. Kill off any PHP processes to update the file.

    Restarting NGINX

    If your server is running NGINX, you must stop NGINX before killing PHP and restarting it. Run the following commands with your admin user.

    [server]$ sudo /etc/init.d/nginx stop
    [server]$ pkill -9 php
    [server]$ sudo /etc/init.d/nginx start
    

Once you finish, the global php.ini is now used for all sites on your server that do not have a custom phprc file enabled.

How do I load PHP extensions on all domains?

On a Dedicated Server, navigate to the directory at /etc/php#/conf.d/. Replace php# with the specific version you're updating.

All PHP interpreters automatically load any configuration files placed in this directory.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?