Make global PHP changes on a Dedicated server

 

Overview

The following describes how to enable global PHP changes on your Dedicated server. You can also set them 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 to enable global changes

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

Making 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 Dedicated 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.1
    [server]$ cd /etc/php81
    PHP 8.2
    [server]$ cd /etc/php82
    PHP 8.3
    [server]$ cd /etc/php83
    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.

Loading 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?