Archive for November, 2008

Installing a SSH Server on Ubuntu 8.10 or 9.10

Wednesday, November 12th, 2008

This code has also been tested and is working with Ubuntu 9.10

If you are planning on using you new Ubuntu installation remotely you will need to install an SSH server.

The most popular choice for SSH server on the linux platform is Open SSH. As with most common packages installation on Ubuntu is very straight forward.

sudo apt-get install openssh-server openssh-client

It may take a while to install all the dependancies if you are installing on a new system. Once it has finished you can test it with

ssh localhost

To access the machine remotely you may need to configure your firewall to allow SSH connections. There are a few graphical applications that will let you do this easily – search Add/Remove Programs for firewall.

Installing Apache and PHP on Ubuntu

Tuesday, November 11th, 2008

This code and article have been tested and work for Ubuntu 9.10

Installing Apache on Ubuntu is relatively simple and can be done in four or five commands with little or no experience.

First we install Apache

sudo apt-get install apache2

This will install and start the web server, create the /var/www directpry for your web pages, create the Apache2 service and install apache2ctl a command line tool to control  the web server.

To test the installation is working open your browser to http://localhost/ you should see a plain page that says “It works!”. That will let you know your web server is running and serving up static HTML pages. Any web pages you put in /var/www/ will be available to view under http://localhost/

If you only want to develop static web pages this will be enough, if however you would like to create scripted pages with PHP you will need to install the PHP 5 binaries and the libraries needed for Apache integration.

sudo apt-get install php5

Will install PHP 5

sudo apt-get install libapache2-mod-php5

will install the Apache PHP module to glue the two pieces together.

Assuming you got no errors you should be setup and ready to develop PHP applications on an Apache server. Restart Apapche for the changes to take effect with

sudo apache2ctl restart

To test that PHP pages are being correctly executed create the file create a test php file.

sudo gedit /var/www/test.php

Put the following code into the file and nothing else

<?php
phpinfo();
?>

open your web browser to http://localhost/test.php if you see a purple page with your System and PHP information on it you have a fully functional development environment.

Congratulations and get your code on!

An eWay Payment Module for CartWeaver 3

Sunday, November 9th, 2008

How this is not a default I do not know, but none the less if you need an eWay payment module for Cartweaver find it below. There is not much to it, I have just modified the example code the eWay provide to fit into Cartweaver 3.

You will need to change a few lines of code to use your eway Customer Id and to receive email notifications.

Line 91: $eWAY_CustomerID = "00000000";    // Set this to your eWAY Customer ID
Line 93: $eWAY_PaymentMethod = EWAY_PAYMENT_LIVE_REAL_TIME_CVN;  // Set this to the payment gatway you would like to use (REAL_TIME, REAL_TIME_CVN or GEO_IP_ANTI_FRAUD)
Line 93: $eWAY_UseLive = true; // Set this to true to use the live gateway
Line 94: $eWAY_CustomerInvoiceDescription = ""; //Max 100 characters Invoice Description

Line 96: $debugEmails = true; // set to true during development to receive XML dumps of the data via email

Line 105: $companyEmail = $_SESSION["CompanyEmail"];
Line 106: $developerEmail =  "YOUR@EMAIL.HERE"; //$_SESSION["DeveloperEmail"] or developer email for testing
Line 107: $company = "YOUR COMPANY NAME"; //$_SESSION["CompanyName"] or another company name

Save the file as CWIncEway.php in Your-Cart-Weaver-Directory/CWLibrary/ProcessPayment/

then in your application.php file change the set the following (around line 87)

$cwGlobalSettings->paymentAuthType = "gateway";
$cwGlobalSettings->paymentAuthName = "CWIncEway.php";

Download eWay Cartweaver Module

I can only offer limited support as I hate Cartweaver and don’t want to venture into that hell fire again anytime soon. This code is by no means bullet proof I knocked it out for a very specific purpose as a one off job. If you find it useful drop a comment.

Remove the WWW and watch your Page Rank sky rocket

Sunday, November 9th, 2008

Getting the Page Rank You Deserve

No matter how many times I see this school of problems on websites I can never get my head around it. It is absolute laziness on the part of your web development team and nothing more. Let me simplify the problem here. Incorrectly managing your website address and in particular the www part will result in diluted page importance and significant search engine ranking penalties.

Got it.

Let me lay out a simple example of the problem for you. Google has 10 points to award your homepage. These points will determine how high up the search results you appear – the higher your score the better. With these 10 points in hand Google scours the web and looks for your homepage address so it can hand over the points.

It finds lots of links to your website and after removing the duplicates it comes up with:

  1. http://www.yourdomain.com
  2. http://yourdomain.com
  3. http://yourdomain.com/index.html

That all looks fine and dandy. Google being the smart camper it is decides that http://yourdomain.com/index.html and http://yourdomain.com/ are both the same page so it removes http://yourdomain.com/index.html from the list leaving just two.

  1. http://www.yourdomain.com
  2. http://yourdomain.com

All things being equal Google then splits the points between the two pages leaving each with 5.

No bad, half way there. Unfortunately your competitors didn’t hire lazy and dodgy to do their website and had http://www.yourcompetitor.com correctly redirected to http://yourcompetitor.com now Google, fully understanding how there website is structured gave there website the full 10 points. As a result their website gets more traffic in a day than you get all month.

Well, you get what you pay for. In case your wondering what it takes to ensure that all the Google page rank is properly credited to your website it’s about three lines added to one file. Not much more than 10 minutes work.

Linux Webserver (.htaccess)

Add the following three lines to a file called .htaccess in the root directory of your website. Create the file if necessary.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

C# ASPX Pages

Place the following code at the very top of your pages and it will achieve the same as the linux code above

if (Request.ServerVariables["HTTP_HOST"].Contains("www"))
{
    string optimalLocation = Request.Url.ToString().Replace("www.", "");
    Response.Status = "301 Moved Permanently";
    Response.AddHeader ("Location", optimalLocation);
    Response.End();
}

Caveats

XCart has login issues if you use the code above to remove the www and still have the www in the store configuration settings. If after you add the code above and you keep getting errors logging into your Xcart store rdon’t panic. Remove the code, log into Xcart and change the store Url to remove the www. Add the code back and all is well.

				

osCommerce, it’s time you stopped

Friday, November 7th, 2008

I have pondered this post for a long time – I expect a certain amount of abuse because of my opinion and I can deal with that – but I stand by my statement – the internet needs to be rid of osCommerce and that goes doubly for it’s bastard love children XCart, CRE Loaded and Co.

I found myself in a strange place a few weeks ago when three customers all running different shopping carts all needed template tweaks, modules coded and shops maintained so I am not just talking out of my arse when I say that the old shopping carts are quite frankly crap.

To go from working on a Shopify template to trying to line up pixels in XCart is like leaving a massage and dragging your naked carcass Bruce Willis style through broken glass.

To go form adding products in an Interspire shopping cart to adding products in osCommerce is no different to eating at Rockpool and having 2 minute noodles for desert.

I don’t mean to slam all the hard work that has gone into what where tremendous shopping carts. Some great coding was done and for a long time it was the best shopping cart available. Those days have well and truly past and the mere existence of these second rate shopping carts is holding back the internet experience for a planet of online shoppers.

I have a new rule – if your shopping cart is osCommerce, XCart, Zen Cart or CRE Loaded I will not buy form you. If you don’t care enough about your products to present them properly I just don’t want them.

I know it seems harsh sticking the knife into a product I used for free for so long but I also believe it is time to start cleaning up the internet. No more Internet Explorer 6, no more java applets and no more old, bloated, 35 click shopping carts with awful or no templating system.

The rant could go on and probably will in the comments but for now I will leave you with a task. Click your way through the osCommerce Live Shops Directory the head over to shopify.com and tell me which website sthe internet is better off without

Installing and Running Firefox 2 on Ubuntu 8.10

Tuesday, November 4th, 2008

This is part of a tutorial on running Aptana on Ubuntu 8.10 but it seems alot of people where using the article to try and get Firefox 2 running on Ubuntu 8.10, so I thought I would give it, it’s own page.

Step 1: Install Firefox 2 on Ubuntu 8.10

The theory here is simple. Change your package sources to Ubuntu 7.10 (Gusty Gibbon) ones, which make Firefox 2 available, install Firefox 2, and then revert your package sources.

Back up our existing source list to make it easy to revert later.

sudo mv /etc/apt/sources.list /etc/apt/sources.list.original

Create a new package source list

gksudo gedit /etc/apt/sources.list

Paste the following list of package sources into this new file and save and close it.

deb http://archive.canonical.com/ubuntu hardy partner
deb http://br.archive.ubuntu.com/ubuntu/ hardy main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu/ hardy-security universe main multiverse restricted
deb http://br.archive.ubuntu.com/ubuntu/ hardy-updates universe main multiverse restricted
deb http://packages.medibuntu.org/ hardy free non-free

Update using the new (well technically old) package source and install Firefox Two.

sudo apt-get update
sudo apt-get install firefox-2

Step 2: Cleaning up the mess and getting the system back to usable

Copy back our original package source list

sudo mv /etc/apt/sources.list.original /etc/apt/sources.list

Update your package sources for next time.

sudo apt-get update

Fixing your title tag

Sunday, November 2nd, 2008

The first part of your website that is usually analysed is the page title and the “meta tags”. There is two reasons for this. Physically these two items are located at the top of the page, and secondly they are very easy to analyse.They are also very important to how and if your website is indexed and found.

What makes a good page title ?

A good page title for both a search engine and for your users is short and tells them what they can expect from the page below. Generally you will find that website analysis tools recommend a page title of 70 to 80 characters or about 7 to 10 words. Other factors to take into account include using on of your keywords in the title tag, not using any special characters or stop words.

Why does my title have to be so short ?

In simple terms terms your title tag has to be 70 to 80 characters because this is all you will need and it is enough to convey the content it represents. It is also about what Google shows in it’s results ands this is what you rely on to grab visitors.

Web page titles are also used in bookmarks, and book marking services like Digg and Delicious so they need to be meaningful in the context of the page as well as attractive to people.

What makes a good title ?

  1. Use good keywords that are also in the page body. Put your highest priority keywords for each page in the title.
  2. Make it unique for every page on your site.
  3. Put the most important keywords first in the title. Words towards the front get more weight for rankings.
  4. Put your brand name last in your title (if you use it at all). The exception being the home page if you have trouble ranking high for you brand name.

Fixing the Web page title in Dreamweaver

Dreamweaver makes it very easy to change the title of a web page.

Open the page in question and switch to design view (Click View -> Design)

At the top of the page (see figure 1 below) is a text field that allows you to change the text field.

Installing and Running Aptana on Ubuntu 8.10 (Ubuntu Intrepid)

Saturday, November 1st, 2008

Since Linux distributions started shipping with Firefox 3 Aptana has become harder and harder to get running error free. After getting a nice fresh Ubuntu 8.10 install running my first task was to get Aptana running so that in a pinch I could belt out some code and get myself paid.

There are only a couple of steps required to get Aptana running on Ubuntu 8.10. Install Java and install Firefox 2. Don’t panic I have never had trouble doing this despite the warning bells you are probably hearing. Firefox 2 and 3 can happily be installed on the same machine without argument.

Step 1: Install Java on Ubuntu

Simple, hardly requires a step.

  1. Go to Applications -> Add/Remove
  2. Change the Show drop down to read “All Available Applications”
  3. Search for Java
  4. Tick and Install Sun Java 6 Runtime – feel free to use one of the others, your choice but I can’t vouch for them working – Aptana says they prefer Sun and that is good enough for me.

Step 2: Install Firefox 2 on Ubuntu 8.10

The theory here is simple. Change your package sources to Ubuntu 7.10 (Gusty Gibbon) ones, which make Firefox 2 available, install Firefox 2, and then revert your package sources.

Back up our existing source list to make it easy to revert later.

sudo mv /etc/apt/sources.list /etc/apt/sources.list.original

Create a new package source list

gksudo gedit /etc/apt/sources.list

Paste the following list of package sources into this new file and save and close it.

deb http://archive.canonical.com/ubuntu hardy partner
deb http://br.archive.ubuntu.com/ubuntu/ hardy main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu/ hardy-security universe main multiverse restricted
deb http://br.archive.ubuntu.com/ubuntu/ hardy-updates universe main multiverse restricted
deb http://packages.medibuntu.org/ hardy free non-free

Update using the new (well technically old) package source and install Firefox Two.

sudo apt-get update
sudo apt-get install firefox-2

Step 3: Cleaning up the mess and getting the system back to usable

Copy back our original package source list

sudo mv /etc/apt/sources.list.original /etc/apt/sources.list

Update your package sources for next time.

sudo apt-get update

Step 4: Downloading and Running Aptana on Ubuntu 8.10

  1. Download Aptana from http://aptana.com/studio/download
  2. Create a script to launch it with the correct settings
    1. Create a new text file called startAptana in your home directory
    2. Add the following
    3. #!/bin/bash
      export MOZILLA_FIVE_HOME=/usr/lib/firefox
      /usr/local/aptana/AptanaStudio
    4. Make the file executable by running
    5. sudo chmod a+x startAptana
    6. from the Terminal

All things being equal you should now be able to ./startAptana and away you go.

Troubleshooting

If you get Java errors and can not find JRE messages change

/usr/local/aptana/AptanaStudio

to

/usr/local/aptana/AptanaStudio -vm /usr/lib/jvm/java-6-sun-1.6.0.10/jre/bin/java

(or whatever the path to your Java runtime is) in your startAptana file