If you `cd` in an install script then it changes the directory for all subsequent install scripts.  Rather than doing it like this, try something like:

     wget --directory-prefix='/var/www' http://wordpress.org/latest.tar.gz
     tar -xzvf /var/www/latest.tar.gz
     chown -R www-data:www-data /var/www/wordpress