Increase File Upload Size Limit

I am work­ing on a project that requires high-lev­el users to be able to upload more than the default Word­Press file-upload lim­it. I’ve done this in the past but I have set it to a mul­ti-domain set­ting. Mean­ing that it encom­pass­es all of my domains being host­ed in a par­tic­u­lar Dreamhost user account.

I want­ed to only increase the file size (again) to some­thing much larg­er than I’ve had before but only for a par­tic­u­lar sub­do­main; as I was using it for stag­ing. Here’s the process that I took to make that hap­pen.1

For all domains being hosted by the user:

  1. Be sure that you have PHP 5.3 (FastC­GI) if you can, or 5.2 if you need to use the old­er ver­sion, for your domain.

    You may check this in your Dreamhost man­age­ment pan­el > Domains > Man­age Domains > Edit (for your par­tic­u­lar domain).

  2. With the above set­ting set, exe­cute the fol­low­ing com­mand via Bash/SSH:
    mkdir ~/.php
    mkdir -p ~/.php/5.3
    touch ~/.php/5.3/phprc
  3. Edit your phprc file with your favorite edi­tor, enter the fol­low­ing set­tings and save:
    upload_max_filesize = 16M
    post_max_size = 16M

Refresh your Word­Press file-upload page and you should now see the update and increase in your file-upload size lim­it. If you would like to only increase the set­ting on a par­tic­u­lar domain like me, fol­low the steps below.

Domain-only increase

  1. Pre­sum­ing that you have set your envi­ron­ment to PHP 5.3 (FastC­GI) as in step #1 above, first cre­ate a cgi-bin fold­er for your domain
    mkdir $HOME/
  2. Clone the default php.ini file
    cp /etc/php5/cgi/php.ini $HOME/
  3. Cre­ate the script wrap­per by exe­cut­ing the fol­low­ing in your shell (SSH/Bash)
    cat << EOF > $HOME/
    exec /dh/cgi-system/php5.cgi \$*
  4. Set the per­mis­sions to your files and direc­to­ries; exe­cute the fol­low­ing also in your shell:
    chmod 755 $HOME/
    chmod 755 $HOME/
    chmod 640 $HOME/
  5. Set up your .htac­cess file locat­ed in your doc­u­ment root $HOME/, and include the fol­low­ing:
    Options +ExecCGI
    AddHandler php5-cgi .php
    Action php-cgi /cgi-bin/php-wrapper.fcgi
    Action php5-cgi /cgi-bin/php-wrapper.fcgi
  6. Last but not least, update your cloned php.ini file (the one resid­ing in your $HOME/ with the size increase. For exam­ple:
    upload_max_filesize = 16M
    post_max_size = 16M

The above will allow you to run your PHP files with the cus­tom wrap­per we have cre­at­ed, and increase your file-upload size lim­it for your PHP appli­ca­tions (e.g. Word­Press). Hope that helps!

  1. These steps are a para­phrase from Dreamhost’s Wiki arti­cle. []

Comments are currently closed.