Category: Wordpress

WordPress 2mb upload limit

After playing with WordPress media and uploading a bunch of images to the website, I found myself asking why WordPress has a 2mb upload limit? Well it turns out that it is not WordPress fault for the upload limit, the problem actually lies in your php.ini and depending on what kind of host you have, you can ask them to increase the limit higher for you or if you have your own dedicated server you can manually change it.

In order to find the correct configuration file, we need to make a php file inside your website.

<?php phpinfo(); ?> 

phpinfo(); example

After we find the correct configuration file we need to open it with your favorite text editor, I like to use nano, it was what I started with and I know the in’s and out’s.  We are looking for the File Uploads section inside php.ini.

 ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = ; Maximum allowed size for uploaded files. upload_max_filesize = 2M 

The last line here is what we need to change, you can change it whatever variable you want, I just increased the size by 300% allowing me to now upload zip files past the 2mb limit.

After messing around with WordPress on a VM, I was able to get to get everything up and running with nice working Permalinks.  But for whatever which reason I could not for the life of me figure out why I kept on getting 403′s on the entire site!  Here is a run down on what I did:

First I made sure everything was working correctly the way I wanted it to be and this meant I had to enable mod_rewrite module in Apache for Permalinks.

ls /etc/apache2/modules-available

ls will return a list of available modules located in the directory, the one we are lookng for is called rewrite.load

Now we need to tell Apache that we want to make mod_rewrite available and ready to use and to that we will need to issue this command:

 

sudo a2enmod rewrite

a2enmod

Now Apache needs to be restarted by: sudo /etc/init.d/apache2 restart

Once Apache is restarted the rewrite module will be enabled but we still need to tell Apache a few other things before we can get pretty Permalinks, and in order to do this we need to open /etc/apache2/sites-enabled/000-default with your favorite text editor and of course permissions to be able to save the file.

The code we are looking for is pretty standard but if you are using VirtualHost then you need to pay attention to which directory your website is running on.

The code is:

<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny allow from all </Directory>

 

We need to change that to this:

<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride none Order allow,deny allow from all </Directory>

All that was really done to this was we changed AllowOverride all to AllowOverride none.  Once you have finished saving the file you need to restart apache again by issuing sudo /etc/init.d/apache2 restart.

We are almost done, what needs to be done next is that we need to log into WordPress and tell it that we want to use Permalinks!  This can be done in Settings>Permalinks.

I picked the Day and the Name for easier reading, but of course you can pick how it can be displayed and if you need help you should look at the WordPress Codex which has a ton of information!

Now after we are done updating the settings for Permalinks if you have write access to the directory WordPress will create and generate a .htaccess file for you, but if you don’t then WordPress tells you that you need to manually edit the .htaccess file.

Now here is what I learned, since we have SSH access to our VPS I used rsync+ssh to sync the files from my VM to the Server, not knowing what the permissions where set on the .htaccess file, after about an hour of comparing permissions, looking at Apache config files. and checking out the log file for Apache I figured that when you went to our homepage that the user didn’t have read permissions to the .htacces file that it would spit out a 403 errors.