Tuesday, December 17, 2013

Can't update wordpress on Ubuntu

I had a wordpress installation on an Ubuntu 13 machine but was unable to update the wordpress. I thought it was due to rwx permission problems but it turned out it was not.

The wordpress folder should be of group "www-data" if you're using apache. Apache by-default runs with www-data group and user. So if your wordpress folder does not belong to this group, apache can not copy the newer version in this folder so it says "I could not update."

I found the solution by following the inverse of the instructions here ( stylishjm at the bottom ).

She said we could change the user and group of apache to our own username but that cause some other problems since it caused:
 ... waiting /var/lock/apache2 already exists but is not a directory owned by "username"

So instead of changing apache's username, I changed the group of wordpress folder:

chgrp -R www-data wordpress

Hope that helps.

Sunday, December 8, 2013

Django Redis backend for sessions on Heroku

Session queries take significant time at each view request. To bypass PostgreSQL and obtain the session information, you can use Redis.

On Heroku, add RedisCloud addon to your app. Then install django-redis-sessions and  add the following lines to your production settings file.

########## REDIS SESSION ###########
from os import environ

redis_url = environ.get("REDISCLOUD_URL")
credential_part, host_part = redis_url.split("//")[1].split("@")
rediscloud, rpassword = credential_part.split(":")
rhost, rport = host_part.split(":")

SESSION_REDIS_PASSWORD = rpassword
SESSION_REDIS_HOST = rhost
SESSION_REDIS_PORT = int(rport)
SESSION_ENGINE = 'redis_sessions.session'
SESSION_REDIS_DB = 0
SESSION_REDIS_PREFIX = 'session'
######## END REDIS SESSION #########