Migrated to Linode, Ubuntu 13.04 upgrade: php mkdir failed problem solved

I’m migrating my blog to my Linode VPS from a shared hosting. While most of the tutorials are very good, especially this part, I was struggling to install wordpress plugin, or any actions that require php to create directory.

It turns out that although the permissions, owner and group are all correct, in which pointed to the myusername, I still could not make my php to create directory to save its life. Until I found this in stackoverflow.

Basically what solved my problem was:
1. sudo nano /etc/apache2/envvars
2. Look for export APACHE_RUN_USER=www-data and export APACHE_RUN_GROUP=www-data
3. Change it to APACHE_RUN_USER=myusername and export APACHE_RUN_GROUP=myusername
4. Save and quit
5. Restart apache

Now I can enjoy my nice Linode VPS happily.