Installing Satchmo on Webfaction
Wednesday, August 22, 2007
For a project I am working on, I had to figure out a quality shopping cart app to use. I tried a couple mainstream solutions and then I found out about Satchmo, a Django-based shopping cart. This seemed like a perfect solution, it had all the power and easy configuration of Django built right in. However, I had some difficulties getting it up and running. Needless to say, I thought some notes on installation might be useful to someone who uses Webfaction and wants to try it out.
Obviously, any modifications you make to your account based on this tutorial, you are responsible for. I do not take responsiblity for any liability or downtime you incur as a result of this tutorial. This tutorial in intended to be carried out on a server that is not production, in case there is downtime or problems resulting from installing Satchmo. Follow at your your own risk!
Setup your account to run Satchmo
The first thing you'll need to do is make sure you have an environment conducive to running Satchmo on Webfaction. This tutorial assumes you are starting from scratch. Extra scratch. Go to your panel (http://panel.webfaction.com) and sign in to begin.
Setup django from the Webfaction control panel
- Mouse over "Domains/websites" and select "Applications" from the menu
- Click on the "Add New" icon (icon just below the options heading, with the green plus sign)
- In the Name field, type "django_apps"
- In the App Type field, select "Django (0.96) with Python (2.5)"
- Click on the "Create" button to install Django
- A success page should appear once Django has been installed
Add a static area for media files
- Mouse over "Domains/websites" and select "Applications"
- Click on the "Add New" icon
- In the "Name" field, type a memorable name for your title for your media files (ex. somesite_media)
- In the dropdown for "App type", select "Static/CGI/PHP"
- Click on the"Create" button
- A success page should appear, once the media area has been created
Add a link to the admin media files
- Mouse over "Domains/websites" and select "Applications"
- Click on the "Add New" icon
- In the "Name" field, type "admin_media"
- In the dropdown for "App type", select "Symbolic link"
- In the "Extra info" field, type the absolute path to your admin media (/home/username/lib/python2.5/django/contrib/admin/media)
- Click on the "Create" button
- A success page should appear, once the admin media area has been created
Add a redirect application
Most modern websites serve the same content to both a www prefix and a non-www prefix domain name. When using Satchmo, you will likely want to utilize a single domain (like somesite.com) and redirect the www version or vice-versa. At first I was trying to support both www and non-www versions and it caused problems with user accounts and security certificates. Installing a redirect with webfaction is no problem, and is the correct way to handle this situation. Note: Versions of this tutorial before March 3, 2008 did not illustrate how to install this redirect.
- Mouse over "Domains/websites" and select "Applications"
- Click on the "Add New" icon
- In the "Name" field, type a memorable name for your title for your redirect (ex. redirect)
- In the dropdown for "App type", select "Static/CGI/PHP"
- Click on the "Create" button
- A success page should appear, once the redirect app has been created
Connect your domain to Webfaction
- Assuming you've already pointed your DNS at Webfaction, mouse over "Domains/websites" and select "Domains"
- Click on the "Add new" icon to add a new domain
- In the name field, type the name of the domain exactlly (ex: somesite.com)
- Click on the "Add new" icon to add a new prefix
- In the field that appears, type "www"
- Click the "Create" button
- You will get a success page that tells you your item has been created
- Visiting your domain should now result in a "Site not configured" message
Connect your website to the domain
- Mouse over "Domains/websites" and select "Websites"
- Click on the "Add new" icon to add a new website
- In the "Name" field, type the name of the site (ex: somesite)
- Do not check the box for Https
- In the "Subdomains" box, select the domain name you will want for the actual main site (ex: somesite.com OR www.somesite.com)
- Under the "Site Apps" area, click on the "Add new" icon
- In the "App" field, select "django_apps", then in the "URL path" field type "/"
- Again, under the "Site Apps" area, click on the "Add new" icon
- In the &"App" field, select the name of your media area. In the "URL path" field type "/media"
- Again, under the "Site Apps" area, click on the "Add new" icon
- In the "App" field, select the name of your admin media area. In the "URL path" field type "/admin_media"
- Click the "Create" button
- A success page should display, telling you your item has been created
- Mouse over "Domains/websites" and select "Websites"
- Click on the "Add new" icon to add a new website
- In the "Name" field, type the name of the site and add a "-secure" (ex: somesite-secure)
- This time, check the box for Https
- In the "Subdomains" box, select the same domain name as above
- Under the &"Site Apps" area, click on the "Add new" icon
- In the "App" field, select "django_apps", then in the "URL path" field type "/"
- Again, under the "Site Apps" area, click on the "Add new" icon
- In the "App" field, select the name of your media area, then in the "URL path" field type "/media"
- Again, under the "Site Apps" area, click on the "Add new" icon
- In the "App" field, select the name of your admin media area, then in the "URL path" field type "/admin_media"
- Click on the "Create" button
- You should get a success page, telling you your item has been created
Connect the redirect to the domain
- Mouse over "Domains/websites" and select "Websites"
- Click on the "Add new" icon to add a new website
- In the "Name" field, type a name for the redirect (ex: www-redirect)
- Do not check the box for Https
- In the "Subdomains" box, select the domain name you will want to be redirected to the actual site (ex: somesite.com OR www.somesite.com)
- Under the "Site Apps" area, click on the "Add new" icon
- In the "App" field, select "redirect", then in the "URL path" field type "/"
- Click the "Create" button
- A success page should display, telling you your item has been created
- Mouse over "Domains/websites" and select "Websites"
- Click on the "Add new" icon to add a new website
- In the "Name" field, type the name for the redirect and add a "-secure" (ex: www-redirect-secure)
- This time, check the box for Https
- In the "Subdomains" box, select the domain name you will want to be redirected to the actual site (ex: somesite.com OR www.somesite.com)
- Under the "Site Apps" area, click on the "Add new" icon
- In the "App" field, select "redirect", then in the "URL path" field type "/"
- Click on the "Create" button
- You should get a success page, telling you your item has been created
Setup your Database
For this example we are going to use MySQL, but you can obviously use postgresql if you want.
- Mouse over "Databases" and select "Create new database"
- Leave the "Machine" field as is
- In the "Type" field, select "MySQL"
- In the "Name&" field, type your account name_sa (ex: someaccount_sa) Webfaction requires that database names begin with the account name and are less then 16 characters long
- In the "Encoding" field, leave utf8
- Click on the "Create" button
- A success message will appear, and a default password will be displayed
- Make note of the name of the database, the username, and the password - located in the green text toward the top of the screen
Install and configure the Satchmo code
Now that you've setup your Webfaction environment to run Django, you should be able to visit your domain name and see the django success message. To run Satchmo, you'll need to download the satchmo code and configure it. Using a ssh client, signin to your Webfaction account to get started.
Rename your project
Once you've signed in, cd into your webapps directory, there should be a django_apps directory, a media directory, and a admin media symbolic link (more if you have other applications installed)
cd into the "django_apps" directory and rename the "myproject" directory to satchmoproject
edit the apache2/conf/httpd.conf direcory and change:
SetEnv DJANGO_SETTINGS_MODULE myproject.settingsto
SetEnv DJANGO_SETTINGS_MODULE satchmoproject.settings
Download the Satchmo code
cd into your home directory
make a new directory called packages
cd into that directory and run this command if you want the newest (with the slight possiblity of bugs) code:
svn co svn://satchmoproject.com/satchmo/trunk/ satchmo-sourceor this command if you want a guaranteed stable release:
svn co svn://satchmoproject.com/satchmo/tags/0.6 satchmo-source*Note: .6 is the current stable version as of this writing. Visit the satchmo project website for the current version number*
Copy the satchmo-source/satchmo directory into the "packages" directory
cd back to your home directory and edit the .bash_profile file
Under the line "# User specific environment and startup programs", add "export PYTHONPATH=$PYTHONPATH:$HOME/packages"
Save the file and exit
Run the command "source .bash_profile" to reload it
Type "echo $PYTHONPATH" to verify that the "packages" directory has been added
Edit the .bashrc file
Under the line "## User specific aliases and functions", add "alias python=python2.5"
Save the file and exit
Run the command "source .bashrc" to reload it
Download the correct Django snapshot
This is a little tricky. Satchmo is very much on the bleeding edge of Django, when Django makes changes to its' code base, it often times will cause errors within Satchmo. The developers at Satchmo do a good job of keeping their versioning in line with updates to the Django code. The best approach is to get the newest code from Satchmo and Django and verify that it works. If you have major problems with incombatitbility, switch to this specific Django snapshot and keep with it until django gets a bit closer to 1.0 (backwards compatability). This step could significantly screw up other django apps you are running off of the same django installation. Proceed at your own risk.
cd into your Python directory (/home/username/lib/python2.5/)
run this command:
svn co http://code.djangoproject.com/svn/django/trunk/ django-sourceor if you've had problems with the newest code, try this
svn co -r 5947 http://code.djangoproject.com/svn/django/trunk/ django-sourceThe new Django code should be downloaded into the "django-source" directory
Copy "django-source/django" directory into the "python2.5" directory (replacing the old django files)
Don't forget to restart your apache!
Configure the settings files
Copy the "settings-customize.py", "local_settings-customize.py" and "load-data.py" from the "packages/satchmo/" directory over to the "satchmoproject" directory under "django_apps"
cd into the satchmoproject directory
Rename the settings-customize.py file to settings.py
Edit the settings.py file and move down to the line that says:
DJANGO_SETTINGS_MODULE = 'satchmo.settings'change to:
DJANGO_SETTINGS_MODULE = 'settings'Next, find the line that says:
DATABASE_ENGINE = ""change to:
DATABASE_ENGINE = "mysql"Next, find the line that says:
MEDIA_ROOT = os.path.join(DIRNAME, 'static/')Change this line to:
MEDIA_ROOT = "/home/username/webapps/*name of media directory*"Next, find the line that says:
MEDIA_URL= "/static/"Change this line to:
MEDIA_URL="/media/"Next, find the line that says:
ADMIN_MEDIA_PREFIX ="/media/"Change this line to:
ADMIN_MEDIA_PREFIX = "/admin_media/"Finally, find the line under "TEMPLATE_DIRS" that says:
os.path.join(DIRNAME, "templates"),modify to be:
"/home/username/packages/satchmo/templates/"Save the file and quit
Rename the local_settings-customize.py file to local-settings.py
Edit the local_settings.py file
Find the database information area, which should look like this:
DATABASE_NAME = "" DATABASE_PASSWORD = "" DATABASE_USER = "" SECRET_KEY = ""Enter the database information you made note of and if you would like, add a security key.
Find the line that says:
CHECKOUT_SSL=Falseand change to:
CHECKOUT_SSL=TrueSave the file and quit
Restart apache
Load the sample data
- Still within the satchmoproject directory, type the command: python load_data.py
- A bunch of data should get created for you to play around with
- Restart apache
Link up the media files
- cd into your media directory ("/home/username/webapps/media")
- Copy the image, css, and javascript folders from /home/username/packages/satchmo/static/ to the media directory.
Configure the redirect
create a file "/home/username/webapps/redirect/.htaccess" with the following content:
RewriteEngine on RewriteCond %{HTTP_HOST} domain.com RewriteRule ^(.*) http://www.domain.com/$1 [R]Note: This will redirect 'domain.com' to 'www.domain.com', you may choose to do the opposite, and if so, simply switch these two in the above code.
All done!
Go to your website and view satchmo in all of its' glory. OK, seriously, now you should be able to alter your images, css, etc. and get a good online store going
Thanks for checking out the article, happy selling.
Comments
David Worley | January 13, 2008
This is a great post. You helped me get my satchmo install up and running with a minimum of fuss. Thanks!
Neum | February 11, 2008
Thank you for posting this. Helped me tons to get Satchmo setup quick and easy on Webfaction.
Daehee | July 11, 2008
Perfect guide. Thanks a lot!
Kyle | September 18, 2008
Very well done. A great guide.
david | September 25, 2008
Hi, thanks! really helpful.. only one hiccup when I run python load_data.py
I get the following
Type 'yes' to erase ALL data and reinstall ALL models: yes All data successfully deleted. Calling syncdb Error: No module named comment_utils
any help would be much appreciated :)
thanks, d.
Brian McKinney | September 25, 2008
Hi David,
Comment Utils is a django comment extension that does a bit of moderation to Django's built in comment system. It looks like comment_utils is a dependency that must be installed on your python path if you plan to use the commenting system with Satchmo. More info on comment utils : http://code.google.com/p/django-comment-utils/
David | September 26, 2008
Thanks Brain! (i now have another issue with the comment but I've pasted that on the satchmo googles group)
David | September 26, 2008
Thanks Brian! (i now have another issue with the comment but I've pasted that on the satchmo googles group)
Kailash Thakur | May 12, 2009
Hi, I was wondering if the steps in this tute were still relevant with the new version of django and satchmo (1.1, 0.9)
Thanks.
panchicore | February 15, 2010
Hi, nice article and thanks for the guide, we are at 2010 and your instructions are for a deprecated django and satchmo version, will be nice is you update this usefull info :) thxs.
Comments have been closed for this post.