I am working on a project that requires high-level users to be able to upload more than the default WordPress file-upload limit. I’ve done this in the past but I have set it to a multi-domain setting. Meaning that it encompasses all of my domains being hosted in a particular Dreamhost user account.
I wanted to only increase the file size (again) to something much larger than I’ve had before but only for a particular subdomain; as I was using it for staging. Here’s the process that I took to make that happen. ((These steps are a paraphrase from Dreamhost’s Wiki article.))
For all domains being hosted by the user:
- Be sure that you have PHP 5.3 (FastCGI) if you can, or 5.2 if you need to use the older version, for your domain.
You may check this in your Dreamhost management panel > Domains > Manage Domains > Edit (for your particular domain).
- With the above setting set, execute the following command via Bash/SSH:
mkdir ~/.php mkdir -p ~/.php/5.3 touch ~/.php/5.3/phprc
- Edit your phprc file with your favorite editor, enter the following settings and save:
upload_max_filesize = 16M post_max_size = 16M
Refresh your WordPress 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 setting on a particular domain like me, follow the steps below.
Domain-only increase
- Presuming that you have set your environment to PHP 5.3 (FastCGI) as in step #1 above, first create a cgi-bin folder for your domain
mkdir $HOME/example.com/cgi-bin
- Clone the default php.ini file
cp /etc/php5/cgi/php.ini $HOME/example.com/cgi-bin/php.ini
- Create the script wrapper by executing the following in your shell (SSH/Bash)
cat << EOF > $HOME/example.com/cgi-bin/php-wrapper.fcgi #!/bin/sh exec /dh/cgi-system/php5.cgi \$* EOF
- Set the permissions to your files and directories; execute the following 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
- Set up your .htaccess file located in your document root $HOME/example.com/.htaccess, and include the following:
Options +ExecCGI AddHandler php5-cgi .php Action php-cgi /cgi-bin/php-wrapper.fcgi Action php5-cgi /cgi-bin/php-wrapper.fcgi
- Last but not least, update your cloned php.ini file (the one residing in your $HOME/example.com/cgi-bin/php.ini) with the size increase. For example:
upload_max_filesize = 16M post_max_size = 16M
The above will allow you to run your PHP files with the custom wrapper we have created, and increase your file-upload size limit for your PHP applications (e.g. WordPress). Hope that helps!