Sunday, April 27, 2008

Moving from Shared Hosting to a VPS Solutions

I've finally taken and plunge and moved away from a shared hosting environment to a VPS solution. To be honest I've been thinking about doing this for about the last 4 - 5 months and was really concerned that I didn't have a the skills to a) get the server running and b) keeping it running.

To give you some background on my situation I'm a web developer by trade and was basically paying about $100 a month to run all my 15 websites, I wanted to cut costs and have more control, I was sick of emailing my web hosting company asking for changes to my site, also .net web hosting in New Zealand is very expensive. By going to a VPS I had no choice but to move it to an overseas server, I think there were 2 .net vps solutions in New Zealand when I went looking and the specs went something like so $70 for 384mb ram and 3gb of ram. Obviously running a few website on these specs was going to be very limited. One good thing about hosting in New Zealand, obviously websites load faster and support help desks and generally fantastic, I use to have all my websites with Web Drive and they were really awesome.

So taking all these things into account I finally found a company i wanted to list with, basically they has 1gb ram 10gb for $50US a month which I thought was pretty damn good, I proceeded through the checkout and the next day the VPS was up and running.

I now had to start planning moving all my sites (something I wasn't looking forward to, other than it was a good learning experience), first couple of things I did on the server (windows 2003 sp2) was run any upgrades that Microsoft suggested to be installed on a web server, then needed to install the .net 2.0 framework and the 3.5 run time.

One thing that got me really confused to begin with was to install my own DNS or not, I'm still pretty ignorant on this fact, i decided it was too hard and fortunately the registrar where all my domains are registered allows DNS control so one thing less to worry about, I did NOT install active directory even though I also thought I needed it, however it turned out I didn't either. I also installed Microsoft SQL Server Express, I know this is probably pretty bad practice, but my websites don't get huge amount of traffic and so I thought this should be fine, I didn't want to pay for a SQL Server database as well if it wasn't really needed, if I need this later then so be it but at the moment it should be fine.

The only thing really to think about was email (i thought I would have to install active directory to handle multiple domains), i spent hours and hours playing around withe SMTP server built into IIS and the pop3 service, basically it was just to hard or actually now looking back on it, its not that hard it just doesn't have anywhere near the functionality that I needed. I didn't know what to do with email, at one point in time I considered buying a second linux vps with cpanel to handle the email but again another expense I didn't want to have. Eventually i discovered hMailServer I had no idea this open source windows based email server even existed, its absolutely fab I suggest you install it and have a play, read as much as you can and follow instructions, I now have it on my VPS running about 10 different domain emails, it can check for viruses, spam, can forward email, can SMTP into it, just awesome! So that was email taken care of.

Right so I started with www.erealestate.co.nz and this is pretty much how it went.

-FTP files from existing host to new host (installed filezilla server on VPS as well)
-Backup existing database and restore on new VPS
-Create new website in IIS6
- Change website to 2.0
- Add erealestate.co.nz and www.erealestate.co.nz to host headers
-Create email accounts in hMailServer
-Change a records and mx records at registrar to point to the IP address of my VPS
-Cross Fingers

This worked fine and repeated the process for my other domains. So far all is going well, VPS has been stable and i'm saving money, I guess the website aren't quite as fast as they use to be but that it to be expected as they now hosting outside New Zealand.

One last thing I did was write a script that backuped my SQL database and my websites and FTPed them to me each night, they are then restored on my local PC. In terms of backup this is probably all I need right.

If you are thinking about moving to VPS then it's really not as hard as you think, its great fun remote desktoping into your own server, installing programs, looking at logs, just remeber don't install to many program :) not like me! Good luck with you VPSing.

Sunday, April 20, 2008

Mutiple Websites + Umbraco

In this short tutorial we are going to learn how to run multiple websites on one instance of Umbraco, this is fantastic if you have common features that you want share between many sites.

I've you followed my GST user control samples (Part 1 | Part 2)
then you will know I have an unusual obsession with GST and VAT calculators and this tutorial is not going to be any different.

In my quest for value added tax calculator dominance i registered two domain names GSTcalculator.info and VATcalculator.info (mainly cos they were only .99c) and what I plan to do is run the calculator we developed in the User Control sample on both websites but only running 1 instance of Umbraco.

The first thing we needed to do was obviously point both domain names to our web server, I'll take it for granted you know how to do this.

Next we can either add both websites to an existing IIS website or create a new one in this case I've created a new website in IIS called Umbraco, pointed the "home directory" to my Umbraco installation and added host header in IIS as per screen shot below.




Because we are going to have a GST calculator(New Zealand) and a VAT Calculator (United Kingdom) we are going to want to have different regional settings eg $ instead of £. For this reason we need to make sure we have two languages defined.



Next we'ved added two new content pages, you can call these whatever you want, if you going to be running many websites then obvisouly it makes sense to name these something you are going to remeber, probably the easiest thing thing to do is call them their domain name.



Now we need add new hostnames to each of the pages we've just created - right mouse click and select host names



Enter the corresponding hostname make sure you add the www version as well.


We should all be set now - if you browse to each website you should see a different version (if you added some content to each page).

While writing this tutorial once i added the host names, Umbraco was still showing me the default homepage of another website higher in the tree, I tounched the web.config so the application would restart and this fixed the issue.

Hope you all enjoyed this tutorial!

Thursday, April 17, 2008

Creating your first Umbraco User Control - PART 2

In the previous article of this series we learnt how to create a user control in visual studio, upload it to our Umbraco site and then how to display it on our site.

In part 2 we are going to learn how to pass variables from Umbraco back to our User Control.

If you followed part one then great we are going to use the same source code and modify the bits we need to.

Because the New Zealand econonmy has turned to crap and the government is constantly changing the GST rate we'd like to update the GST rate in Umbraco and not in our source code.

1. Open your Umbraco user control in Visual Studio.

2. Last time we had some code like such



double GST = 1.125;
double Result;
Result = double.Parse(txtAmount.Text) * GST;
lblResult.Text = Result.ToString("0.00");


This time want to replace this line (double GST = 1.125;) with a dynamic value from Umbraco.

We need create a variable to hold the GST amount eg
private Double gstRate;

3. Next create a public property so we can access it from Umbraco and assign it to the variable we created above. eg



public Double _gstRate
{
get { return gstRate; }
set { gstRate = value; }
}


4. Replace double GST = 1.125; with so:



Double mutipler;
mutipler = gstRate / 100 + 1;
Double Result;
Result = double.Parse(txtAmount.Text) * mutipler;
lblResult.Text = Result.ToString("0.00");


5. Build the soluion and upload to to your Umbraco Bin directory and move to the Umbraco control panel.

6. Go to your developer --> macros and select the Macro you created last time or if you want you can create a new macro.

7. Select the "browse properties" button


8. The public properties in you usercontrol should be displayed in this page


9. Click the parameter tab at the top of the screen and make sure the type selected is text.

10. Save your macro and return to the content page where you are going to place GST Calculator.

11. Insert the macro and you should see the option to input your GST rate.


12. Publish your page and you should be away laughing

13. To edit the rate you can either delete the macro within the page and reinsert it or view the HTML using the html button on the rich text editor and changing the rate manually in their.

Hope you enjoyed this little tutorial - please make any suggestions of tutortial you would like to see! The GST calculator is running live my umbraco site here

You can download a copy of the Visual Studio 2005 version here