PHP Max Upload Size – Dreamhost

I’ll preface this post by stating that I don’t endorse Dreamhost and don’t particularly care for it as a service, however, I work with several sites that are hosted there.

That being said, previously when I needed to change the maximum upload size that PHP would allow, I’d simply run the dh-phpini script and modify the ini file to match my desired upload size. The last time I tried using this, it did not work successfully so if you’re having trouble with that, here’s a work around. Note: the goal of this post is to change the following PHP variables in the ini file:

POST_MAX_SIZE and UPLOAD_MAX_FILESIZE

If you’ve got a better way, please feel free to leave a comment. Also, it’s worth noting Dreamhost doesn’t support (although they do allow) this type of modification and won’t help you if you mess things up… I’m not responsible either :-)

To get started, you’re going to need to have access to a shell account on the server. You can set this up under ‘Manage Users’ from the Dreamhost panel).

Step 1:

SSH into the server like so:

ssh username@domainname.com

You’ll possibly be prompted to verify that you would indeed like to connect to this unknown server. If you choose to accept, you’ll then be prompted for your password. Go ahead and put that in.

Next, assuming your ssh account’s home directory is the home directory for the account, you’ll need to make a directory called ‘.php’ and inside of that directory we want a folder named ’5.3′, you can do that like this:

mkdir -p .php/5.3

This brings up an important point. For this configuration to work, you’ll need to be running PHP 5.3 on that domain. You can change this under the ‘Manage Domains’ section of the Dreamhost panel.

Next we’ll want to cd into our newly made directory:

cd .php/5.3

Next we want to copy the “generic” or default php.ini into our new directory:

cp /etc/php53/php.ini $HOME/.php/5.3/php.ini

We’ll use the nano text editor to edit the file:

nano php.ini

Next, you’ll want to find the POST_MAX_SIZE and UPLOAD_MAX_FILESIZE and edit those values.

Now Press Control + X and Save.

We now need to restart PHP:

killall -9 php53.cgi

If all went as planned, your max upload size should now be changed.