Oct 28

Recently I had to create a clone of this blog site so we can apply upgrades and test these out without fear of breaking our actual blogs. Here’s a list of steps I followed. Hopefully, it’ll help others.

Assumptions:

  •    existing blog URL: http://a.com.
  •    New blog URL: http://b.com/wordpress
  •    Existing blog is installed in /var/www
  •    New blog will be installed in /var/www/wordpress
  •    The MySQL database for wordpress content is called ‘wordpress’. Username and passwords are also ‘wordpress’
ssh root@a.com
 cd /var/
 tar cf wordpress.tar www
 bzip2 wordpress.tar
 mysqldump --add-drop-table-uwordpress -pwordpress -Dwordpress -hlocalhost > db.backup
 bzip2 db.backup
 scp wordpress.tar.bz2 db.backup.bz2 root@b.com:/var/www
ssh root@b.com
 cd /var
 tar jxf wordpress.tar.bz2
 mysql -uroot -p<mysql root="" pw="">         
 create database wordpress;
 GRANT ALL PRIVILEGES ON wordpress.* to 'wordpress'@'localhost' identified by 'wordpress*'; 
 exit;  
 cd /var/www  bunzip2 db.backup.bz2 
 mysql -uwordpress -p'wordpress' -Dwordpress -hlocalhost < db.backup  
 cd /var/www
 mkdir wordpress 
 cd wordpress 
 mv ../wordpress.tar.bz2 .   
 tar jxf wordpress.tar.bz2  
 mv www/* .  
 rm -rfwordpress.tar.bz2 www     
 cd /var/www    
 mysql-uwordpress -p'wordpress' -Dwordpress -hlocalhost
    update wp_posts set guid=REPLACE(guid,'http://a.com','http://b.com/wordpress');         
    update wp_options set option_value='http://b.com/wordpress/' where option_name='siteurl';   
    exit;

You should be able to login as admin at http://b.com/wordpress/wp-admin

Goto Settings/General and change all instances of http://a.com to http://b.com/wordpress

You might also have to goto your currently selected theme and make sure URLs are changed. Some themes have URLs embedded in them.

 

Tagged with:
Jun 12

The usual and perhaps recommended way to run wordpress behind nginx is via nginx and fast-cgi. You can easily find these articles on google. However, that’s quite a complex setup and it far easier to just run apache2 + php + wordpress behind nginx and use nginx as a proxy. It’s probably a waste of memory to run the monstrous apache along with nginx but it’s much simpler setup and between my time and computer memory, my time is far more expensive!

Just install wordpress following their usual instructions, then change the apache port to something other than 80 (since nginx is running on 80). Following example assumes apache running at 800.

Then, add following to your nginx conf:

server {
  listen   80;
  server_name  your.blogserver.com;
  location / {
    proxy_pass http://localhost:800;
    proxy_set_header Host $host;
  }
}

Restart your nginx and http://your.blogserver.com should now be your wordpress blog.

Pay special attention to proxy_set_header directive. It took me a while to figure out why wordpress was redirecting itself to ‘localhost’ !!!

Also, the apache config must have DirectoryIndex index.php set.

Tagged with:
preload preload preload