Archive for March 2009
How to run two wordpress blogs on one web site
There is ample detailed information out there on installing wordpress. However, I wanted to just provide a small supplement about setting up two distinct wordpress blogs within a single apache2 web site. The system I am using is Ubuntu Linux 8.10, but other than the package installation, the configuration steps should be the same on other linux distributions.
As a first step, read through the WordPress Installation Instructions. You will find them to be thorough and clear. The starting point for my setup is that I already had a web site up and running under apache2. I just wanted to add the WordPress (and underlying MySQL database) setup and have two separate blogs with separate themes and content.
So here’s my starting setup:
- Ubuntu 8.10 on an amd64 system
- apache2 already installed and working
- static content for the web site deployed in
/var/www/example.com - MySQL and WordPress are not yet installed
Install wordpress and mysql
First let’s install wordpress and mysql. I’ll do this on the command line using the apt-get program, but you can use one of the graphical options as well
sudo apt-get install wordpress virtual-mysql-server
You should see a bunch of packages that will get installed and press y to proceed. The MySQL install will prompt you to create a new mysql root account password, so go ahead and do that.
Set up the wordpress databases
OK, so let’s say we are going to call our blogs blog1 and blog2. We need to create mysql databases for them. Note that you may see tutorials telling you you can store the data for two separate blogs in one database. While true, two databases is a much cleaner way to go. End users shouldn’t be going around making up database table names. So, we are going to use the mysql command line tools to do this. Again, the wordpress docs here are fine and describe graphical alternatives as well. Let’s connect to mysql (use the password you created above) as root and create the databases. We’ll call them blog1 and blog2 and we’ll also set up user accounts inside mysql that wordpress will use to access the databases. Again for simplicity, we’ll also call the user accounts blog1 and blog2. Replace “MakeUpPassword” with your own chosen password.
mysql -u root -p create database blog1; GRANT ALL PRIVILEGES ON blog1.* TO "blog1"@"localhost" IDENTIFIED BY "MakeUpPassword"; flush privileges; create database blog2; GRANT ALL PRIVILEGES ON blog2.* TO "blog2"@"localhost" IDENTIFIED BY "MakeUpPassword"; flush privileges; quit;
Install wordpress files and configure DB access
OK, when we installed wordpress above, Ubuntu put a copy of the wordpress PHP files into /usr/share/wordpress, so now we’re going to make 2 copies, one for each blog, underneath our web site’s document root. Note that since these are two blogs in the same web site, we don’t want either blog to be the top level home page of the site, so each gets its own separate subdirectory.
sudo mkdir -p /var/www/example.com/blog1 /var/www/example.com/blog2 sudo cp -r /usr/share/wordpress/* /var/www/example.com/blog1 sudo cp -r /usr/share/wordpress/* /var/www/example.com/blog2 sudo chown -R www-data:www-data /var/www/example.com/blog*
Now I should note that Debian/Ubuntu has a customized wordpress configuration. Often, these are well crafted by the experts and will save you a lot of time and hassle if you follow the patterns they suggest. In this case, I don’t think their setup exactly matches my goal of two different blogs under one web site, so I am bypassing their pattern and doing my own simple alternative. So what happens is that by default the file /usr/share/wordpress/wp-config.php is a symbolic link to /etc/wordpress/wp-config.php, and when we copied these files, that symlink was copied too, which means if we aren’t careful both of our blogs will point at the same database, making them one blog instead of two! So we do the following:
sudo rm /var/www/example.com/blog*/wp-config.php sudo cp /usr/share/wordpress/wp-config-sample.php /var/www/example.com/blog1/wp-config.php sudo cp /usr/share/wordpress/wp-config-sample.php /var/www/example.com/blog2/wp-config.php sudo chown -R www-data:www-data /var/www/example.com/blog*
OK, now each blog has it’s own separate copy of wp-config.php. Go ahead and edit those files to point blog1 at the blog1 database and blog2 at the blog2 database using vi or your text editor of choice. When done, they should look as follows:
/var/www/example.com/blog1/wp-config.php
<?php
// ** MySQL settings ** //
define('DB_NAME', 'blog1'); // The name of the database
define('DB_USER', 'blog1'); // Your MySQL username
define('DB_PASSWORD', 'yourpasswordhere'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
// Change SECRET_KEY to a unique phrase. You won't have to remember it later,
// so make it long and complicated. You can visit http://api.wordpress.org/secret-key/1.0/
// to get a secret key generated for you, or just make something up.
define('SECRET_KEY', 'put your unique phrase here -- yes you change this now'); // Change this to a unique phrase.
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-content/languages.
// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>
/var/www/example.com/blog2/wp-config.php
<?php
// ** MySQL settings ** //
define('DB_NAME', 'blog2'); // The name of the database
define('DB_USER', 'blog2'); // Your MySQL username
define('DB_PASSWORD', 'yourpasswordhere'); // ...and password
define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
// Change SECRET_KEY to a unique phrase. You won't have to remember it later,
// so make it long and complicated. You can visit http://api.wordpress.org/secret-key/1.0/
// to get a secret key generated for you, or just make something up.
define('SECRET_KEY', 'put your unique phrase here -- yes you change this now'); // Change this to a unique phrase.
// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = 'wp_'; // Only numbers, letters, and underscores please!
// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-content/languages.
// For example, install de.mo to wp-content/languages and set WPLANG to 'de'
// to enable German language support.
define ('WPLANG', '');
/* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>
Permalinks
OK, now let’s make sure we have mod_rewrite enabled for wordpress permalinks, then we restart apache2 to get our new software and config to take effect. We’ll also make sure we have a writeable .htaccess file so wordpress can set it up for us.
sudo a2enmod rewrite sudo apache2ctl restart sudo touch /var/www/example.com/blog1/.htaccess sudo touch /var/www/example.com/blog2/.htaccess sudo chown www-data:www-data /var/www/example.com/blog*/.htaccess sudo chmod 644 /var/www/example.com/blog*/.htaccess
Almost done, we can now point a web browser to http://localhost/blog1/wp-admin/install.php and fill out that form and launch the wordpress self-install. Repeat the process for blog2 at http://localhost/blog2/wp-admin/install.php. Now, this is going to set up the blog in the database and create the admin user with a default password. If your computer has a mail transport agent running, you should get the email with the default password. If not, you won’t, which is what happened to me, so we can just set the admin password to one of our choosing. First, we need to know the MD5 checksum of our chosen password. You can use this online form to get the MD5 of your password, but sending your password to some random web site in clear text is too insecure for me. Therefore, if you have python, you can use this little python one-liner to do it. This will securely prompt you for your password and print out the corresponding MD5. Nothing is sent over the network. You will end up with a 32-character hex string. Use this instead of the For details from wordpress, read resetting your password in the wordpress online docs. The cheat sheet is below.
python -c "import getpass,md5;m=md5.new();m.update(getpass.getpass());print m.hexdigest()"
OK, so let’s set this password into mysql so we can start managing our blog
mysql -u root -p use blog1; update wp_users set user_pass="useyour32charhexstringmd5here" where user_nicename="admin"; use blog2; update wp_users set user_pass="useyour32charhexstringmd5here" where user_nicename="admin"; quit;
OK, you are good to go to http://localhost/blog1, log in as admin, and start managing your blog. You can go in and set up custom pretty permalinks in the admin section and when you save, wordpress should be able to write the rewrite settings to the .htaccess file we set up for you. Good luck and happy blogging!
Music subscription and Rhapsody
Flat fee music subscription service has changed my life. I wish there was some less dramatic way to put it, but it’s the honest truth. I don’t remember exactly when, but somewhere in late 2006 probably, after reading this Joel on Software – The infinite music collection article, I was intrigued by the idea and did a little shopping. I know I looked at Napster, Virgin, Yahoo, and Rhapsody at least. I think I initially went with Rhapsody because of the Sonos integration. I experimented for a bit listening on the computer and then I think that Christmas I asked for a basic set of Sonos gear, which was and still is exorbitantly priced.
OK, so first some comments on the whole notion of subscription music service. It’s amazing. For someone like me with a voracious appetite for new music cultivated spending long hours every week in the fantastic Oberlin Conservatory Music Library, it was complete drooling brain-fry. It was a bit overwhelming at first. There were numerous aspects of this arrangement that were just awesome. Obviously, the size of the library is number one. Having extremely ecclectic and somewhat obscure taste in music, I was worried that it would be basically a top-40 archive that I would quickly grow bored with. This was not the case. The collection of jazz, classical, and less main stream stuff was really quite good. Now, every CD in my personal library is not available, but the service library as a whole is so infinitely broad and compelling that I don’t care that much.
Secondly, there is the complete removal of the financial penalty for exploring. Before I expound on this let me just state that I listen to whole albums in totality in order. Fuck shuffle. Fuck 30 second previews. I usually listen to complete albums start to finish numerous times before I decide how I feel about them. In addition, when checking out a new artist, I actually prefer to listen to all the albums in chronological order. Sometimes I’ll scan a “best of” to see if it’s worth my time, but usually I go straight for the debut album. For years, I would gather suggestions from peers, and then go plunk down $17 for a CD. No more. Now I can try relentlessly at full speed for a flat fee. This is fantastic and significant. Now I can actually listen to artists I know I don’t care for, if only to better understand what it is about them that I don’t like.
Third, in the jazz and classical genres, musicians are vastly more prolific compared to their pop/rock peers. Go try to get the complete recordings of Miles Davis. Be sure to bring like $1500. With a flat fee subscription, I can go and listen to LOTS of music by folks I like. One of the first things that got me completely hooked on this was listening to a 10-disc set of Steve Reich: Works 1965-1995. This retails at amazon.com for $99.98. So the trade-off for this ONE collection is own this collection forever or get over six months access to millions of songs online.
Fourth, you can compare recordings to your heart’s content. I have a physical copy of the venerable Emerson String Quartet’s recording of the six Bela Bartok String Quartets. Currently going for $22 on amazon. It is a cherished record in my collection. However, the chances of me buying another recording of this work are slim to none, even though I would love to hear various interpretations. Rhapsody has no less than ten complete recordings of these works available! When it comes to jazz and you want to learn a new song, Rhapsody is going to give you about thirty recordings to choose from. No better way to truly absorb the song’s full meaning from the repertoire by listening to numerous different recordings.
Fifth, there is no personal music library management. I’ve spent hours and hours labeling my CD collection (over 800 discs), ripping them, fixing the cddb track metadata, transferring stuff to portable devices, re-transfering it when it gets corrupted, etc. Then there’s the idea that I have to keep this all backed up. I have so far ripped about 30 GB of music and don’t really want to deal with backing that up. With a subscription, all the music is just instantly there. It’s all indexed and searchable. The track metadata is correct. I don’t have to personally back it all up.
Sixth, it works with portable players in a reasonable way. I think for the next Christmas I asked for the SanDisk Sansa e280R portable MP3 player that is integrated with Rhapsody. You can download tracks to the device and as long as you connect it once a month to verify your subscription is active, you are good to go. It works pretty well and doesn’t really add any hassle. I’ll be posting another entry soon about the various devices (basically all bad) I have used with Rhapsody and how they work.
So I’m totally hooked on this model of flat fee all you can eat subscription music. I was initially concerned that streaming this in real time would not work, but honestly there have been almost no glitches. Either the service is working or it isn’t, but it doesn’t do any buffering interrupting the song or anything like that, which would be a complete deal-breaker. To try to listen to this much music on iTunes would cost me hundreds of dollars a month.
So, let’s look at some of the cons. There are no linear notes. I do miss that. I also miss detailed personnel listings per track. However, when I really am interested in that, the info is usually available online if I can remember to go look it up. As of now, in order for this to work, it relies on Plays For Sure Digital Right Management (DRM) scheme. Generally I am against DRM, but if it is required in order for the music industry to be willing to make a subscription service available, so be it.
OK, so that is mostly focussing on the subscription model in the abstract. Let’s talk about the Rhapsody service in particular. After a few years of using it, overall I’d probably give it about 7 out of 10. It’s good, but it has some annoyances. On the plus side, the web based Rhapsody online product, which was formerly a proprietary plug-in that gave me a few hassles on Linux, is now entirely standard flash based app. In general it works great on linux however my new laptop I installed 64 bit Ubuntu and the rhapsody flash app won’t log in currently. I’ll be contacting support (sigh) to yell at them to make it work.
So some of the annoyances include inability to re-order tracks in your queue/playlist. You can append to the end of it and delete items, but you can’t reorder. Again, since I generally listen to whole albums it doesn’t bother me much, but sometimes it can be a real pain. Also, their web site used to have a frigging NORMAL LOGIN HTML FORM, thus I could save my credentials in my browser and not be bothered with it. Now the flash app itself prompts for credentials which means I have to re-type my password a few times a day. I asked support to make it go back to the old way but you can guess how that went.
Reliability and bill payment have been good. The Windows application that I need to use to actually transfer music to a portable player is decent. It’s better than the flash app, but still a bit cumbersome. It’s got a web browser pane embedded in it, which has all the annoyances of a web browser, but not all the screen components and tools to properly manage it. Here they have a proper playlist editor window. Ideally I would be able to transfer to my portable from a linux application, but I have realistic expectations here. It ain’t going to happen.
Rhapsody has user and celebrity playlists, both of which are a great way to explore and check out new stuff.
So if you are a big music fan, and still haven’t tried a subscription service, give it a shot. I can never go back. Look for more posts soon about my experierces with music player devices over the years.