On our WordPress site we want to allow the site manager the ability to upload PDF files which can then be downloaded by our blog viewers. While working out this process we ran into a problem with the file size; any file larger than 2 megabytes was not allowed to be uploaded to the site.
Rather than having this setting located somewhere within WordPress, it turns out that the setting is set by the PHP installation. (PHP is the language that WordPress is written in, and WordPress the application is written as a series of PHP files).
As I was working through this issue, the first embarrassment was that I couldn’t even find the WordPress installation on my Linux server. Usually WordPress is supposed to be installed somewhere relatively transparent, like the /var/html/wordpress folder. Instead mine was buried under /srv/www/li999-999.members.linode.com/public_html; somehow related to my virtual host from Linode
As my plumber says, when looking at the latest plumbing problem in our basement, “I wonder why they did that?” Whatever. The way I finally found this out was to search for the one file that is in every WordPress site; wp-config.php. I did this by firing up the FileZilla FTP program, and doing a search for remote files.
Having found the root directory of my WP installation, I now needed to find the location of the PHP configuration file. I used a similar search in FileZilla and came up with two php.ini files. Which was the “real” one?
Actually, I didn’t need to do that. Instead, I needed to get to have a script that calls the phpinfo() function which displays a nice list of all the php configuration parameters. Placed in the root directory of my web server, and then called from a web browser, this script displays all of the inner workings of the php configuration of my site. Here’s the script:
// Show all information, defaults to INFO_ALL phpinfo();
This script is saved as GetPHPInfo.php and copied back to the root directory of the web server.
Call this script in the web browser and it produces the following:
The above is just the tip of the iceberg. Scrolling waaaay down, I find the following parameter in the “core” section of the page:
That is the size restriction, and it is this parameter that I need to change. I’m thinking that 12 megs should be plenty. Looking back up top in the 6th line, I see the “Loaded Configuration File” is located at: /etc/php5/apache2/php.ini This is the file I’m going to change. So, its back to FileZilla to find it, download it and edit it in Notepad++
I downloaded the wp-config.php file to my local machine using FileZilla. Then I edited the file using Notepad++. to change the 2M to 12M. Then I uploaded the file via FileZilla back to the web server.
At this point I needed to reboot the web server, Apache2. Depending on the your installation, there are a couple ways to do this at the command line:
$ sudo /etc/init.d/apache2 restart
Or, in the case of the lazy systems administrator, I just rebooted the whole server. This takes less than two minutes.
The result is now we can upload files that are a maximum of 12 megabytes in size.
I get to do this on another WordPress server too. Oh joy!