How to Increase PHP Max Upload Limit in DreamHost

According to DreamHost’s Knowledge Base, every installation of PHP comes with default settings which are usually fine for most websites. Occasionally, the needs of a website makes it necessary to adjust these PHP settings. For example, your site may need to upload files larger than the current PHP upload limit allows.

The default size limit for uploading files is 64MB, which may be far too small for your needs. In that case, you would need to create a php.ini (phprc) file, or access the existing phprc file, and update this value.

Creating or updating an existing phprc file can be done using FTP or SSH. In this post, I will only show How I increased the max upload size limit in my DreamHost domain account using SSH.

Adding a phprc file using SSH

  1. Logged-in to my server via SSH using Putty.
  2. Typed the ‘pwd’ command to check the current directory I was in.
    [server]$ pwd

    Remember to first check which version of PHP your site is using in my case it’s 7.3.

  3. Run the following command to create the .php directory and a sub-directory named 7.3 inside it. If you are using a different version like 7.2, you just need to replace the 7.3 with 7.2 from the following code.
    [server]$ mkdir -p ~/.php/7.3
  4. Changed directory to the directory I have just created using the following command.
    [server]$ cd .php/7.3

    Running the ‘pwd’ command should print the following in the console showing the full path of the php version.

  5. Run the following to create the phprc file.
    [server]$ nano phprc

    And the nano editor will be opened having a default content automatically added by Dreamhost as shown below.

    ; {{{ The following lines were automatically added by DreamHost
    ; }}} That's all from DreamHost
  6. It’s now the time for us to add php directive to increase max upload size and other limits.

    Your code should be placed below the DreamHost code block.

    If you place your code within the semicolons, it will be overwritten by the server.

    ; {{{ The following lines were automatically added by DreamHost
    ; }}} That's all from DreamHost
    upload_max_filesize = 300M
    post_max_size = 305M
    max_execution_time = 500
    max_input_time = 500

    I added 4 lines after the DreamHost’s code block. Setting up upload_max_filesize to 300M. and post_max_size to 300Mb as well as the max_execution_time and max_input_time to 500.

To upload larger file size, the post_max_size must be greater than the upload_max_filesize.

That’s it for increasing the PHP max upload limit in DreamHost.

But there’s one last thing we need to do to ensure our changes in the phprc file takes effect by killing off the PHP processes which can also be done via SSH.

Run the following command to see what processes are running.

[server]$ ps aux
user     9962  0.0  0.0  18824  3384 pts/0    Ss   May17   0:00 -bash
user    25985  2.5  0.3 506704 118188 ?       S    00:33   0:07 php73.cgi
user    28716  0.0  0.0  34408  2764 pts/0    R+   00:38   0:00 ps aux

Now, run the following command to kill the process php73.cgi running. Make sure to replace “user” with the SSH user.

[server]$ killall -9 php73.cgi -u user

Confirming Changes

After you’ve edited the file and killed off all PHP processes, you should check to confirm the values have updated. You can do this by creating a phpinfo.php file.

Cromwell Bayon

He is a self-tutored programmer and a Full-Stack Developer. He strives to excel in the newest technology as possible. He has a very high sense of technicality and analytical skills which allows him to resolve any kind of issues related to technology. He also loves woodworking. Read more about him here...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.