WHM/Cpanel Tips

I recently switched from Debian Squeeze/Cherokee webserver back to a more typical VPS setup with CentOS/WHM/Cpanel. Cpanel does make it easy to manage many sites… but it can make other common tasks a bit more difficult. For example, I could not get git to install until I found out that cpanel disables perl upgrades. (Thanks Nick! http://www.cmdln.org/2010/05/07/install-git-on-centos-cpanel-server/)

Nick’s suggested command worked like a charm.

yum --disableexcludes=main install git

My next problem was that I don’t want to use the default document root for all of my sites. In cherokee you can easily set the document root for each vhost through their admin interface. Not so, with cpanel. After a bit of searching I found that you can edit individual vhosts here:

/var/cpanel/userdata/$username

After editing run:

/scripts/ensure_vhost_includes --user=$username

WP E-Commerce Basics

WP E-commerce is a powerful plugin, but getting started can be a bit messy. Here are some tips.

Go to the checkout page when you click “Add To Cart”

The add-to-cart button uses a javascript to stay on the same page while submitting the product form. To make it go to the checkout page we want to remove the javascript. This can be done by changing the name of the containing element. The javascript effects form.product_form. If you look at the product template you can change the class here:

The other thing you need to change is the action. The default form action is the same page on which the form exists. Change that to the checkout page.

Fix the checkout form

The checkout form can start off pretty messy looking, depending on your containing theme. What I like to do when styling plugins is create a separate stylesheet for the plugin, then call it at the bottom of header.php. That way the styles will override the plugin styles.

The checkout form template is wpsc-shopping_cart_page.php

To edit it copy this to your theme directory. WPEC has a tool that does this for you in Settings — Presentation. Don’t forget to flush the theme cache.

Two carts are displaying on checkout page

Change the shopping cart settings to widget instead of page in presentation.

Checkout page is broken

If there are no address fields showing on the check out page make sure that if “enable shipping” is selected you have valid shipping methods.

Checkout page has break tags in the form fields

Remove line breaks from the label tag. Thanks shivaweb.

Django – restart fcgi

This post is mostly for me… to help remember some things about working with django. Because django is loaded into memory on start-up you need to restart the process when changes are made to the code. I am currently using django with fcgi on a cherokee server.

In the terminal to your server type:

ps -ef | grep python

Look for the process ID which is running django. Then type:

kill -HUP [processid]

Now that you have killed the process you need to restart it. I usually just copy/paste the python command that is listed when I grep the processes. It looks something like this:

python /path/to/django/manage.py runfcgi protocol=scgi host=127.0.0.1 port=35782

You can also set this up to be automated, but I have not done that yet.

https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/

RSS Word Counter

My good friend Jason Scott Furr had the idea to set up a junk email account and analyze the emails to see which words occur the most. I built this little script in PHP which grabs the gmail account via RSS and analyzes how many time each word occurs in the subject. The script outputs an XML file which Jason imports into Quartz Composer and converts to OSC for video mixing (screenshots coming).

There is a filter to leave out common words such as “the, and, you” etc to make the results more interesting. The filtered words can also be edited in the script.

Though the script currently analyzes an email account, it can be used with any RSS feed or feeds. Simply enter any feed urls at the top of the script and it will analyze all of them together.

You can view the results of the email experiment or download the php script.