Increase File Upload Size Limit

I am work­ing on a project that requires high-level users to be able to upload more than the default Word­Press file-upload limit. I’ve done this in the past but I have set it to a multi-domain set­ting. Mean­ing that it encom­passes all of my domains being hosted in a par­tic­u­lar Dreamhost user account.

I wanted to only increase the file size (again) to some­thing much larger 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 (FastCGI) if you can, or 5.2 if you need to use the older ver­sion, for your domain.
    increase-file-upload-size-01

    You may check this in your Dreamhost man­age­ment panel > 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 limit. 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 (FastCGI) as in step #1 above, first cre­ate a cgi-bin folder for your domain
    mkdir $HOME/example.com/cgi-bin
  2. Clone the default php.ini file
    cp /etc/php5/cgi/php.ini $HOME/example.com/cgi-bin/php.ini
  3. Cre­ate the script wrap­per by exe­cut­ing the fol­low­ing in your shell (SSH/Bash)
    cat << EOF > $HOME/example.com/cgi-bin/php-wrapper.fcgi
    #!/bin/sh
    exec /dh/cgi-system/php5.cgi \$*
    EOF
  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/example.com/cgi-bin
    chmod 755 $HOME/example.com/cgi-bin/php-wrapper.fcgi
    chmod 640 $HOME/example.com/cgi-bin/php.ini
  5. Set up your .htac­cess file located in your doc­u­ment root $HOME/example.com/.htaccess, 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/example.com/cgi-bin/php.ini) 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­ated, and increase your file-upload size limit 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. []

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>