Last monday I signup a new VPS (Virtual Private Server) at Rackspace. Let's go!
Why do I need a VPS? Why not a shared host company?
You don't need, but it's better than a shared host. Using a shared host (usually use cPanel/WHM) you have to follow the company's rules. If you want to try some framework, for example, that uses PHP 5.3 and your shared host has PHP 5.2, you are in a dead end. Shared hosts don't allow you change that. Using a VPS you have all control about the server.
Getting a VPS
I like the Rackspace service. They have a very fast support (live chat 24/7/365) and the host service is very good. I recommend them! But, with these steps I should you can get any VPS you want.
Choose the VPS you want (at Rackspace): http://www.rackspace.com/cloud/cloud_hosting_products/servers/pricing/
Get the VPS and login the Cloud Controle Panel: https://manage.rackspacecloud.com
- You'll se your main menu in the left side. Let's access: Hosting >> Cloud Servers.
- Here you'll se all servers you have at Rackspace. Click "Add Server" to create one
- Select the Operational System you want. My choose was Ubuntu 11.10 (Oneiric Ocelot)
- Give the server a name, like **|*server.mydomain.com**|*, and select the amount of ram and disk you want
- Wait for the server creation. After 1, 2 minutes you'll receive an e-mail with your IP and password
Let's access your new VPS using SSH and type your password (mailed by Rackspace):
ssh email@example.com firstname.lastname@example.org's password: <type your password>
In my case, I use LAMP with Zend Framework. So let's install PHP, MySQL and Apache.
apt-get update // to refresh your apt repositories apt-get install apache2 apt-get install mysql-server apt-get install php5 apt-get install phpmyadmin apt-get install zend-framework apt-get install proftpd // access by FTP
Webmin - Control Panel
For Control Panel I prefer Webmin. It's free and VERY VERY good...
Follow the steps at Webmin site: http://webmin.com/deb.html
Edit the /etc/apt/sources.list file and add these lines in the end:
deb http://download.webmin.com/download/repository sarge contrib deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Save the file. In the shell get the GPG key...
cd /root wget http://www.webmin.com/jcameron-key.asc apt-key add jcameron-key.asc
Give APT a refresh and install Webmin throw apt-get:
apt-get update apt-get install webmin
Postfix - Sending e-mails
You'll need a mail server to send e-mails using your applications. Let's install Postfix. It's better than sendmail (my opinion).
apt-get install postfix
Follow the step in the Daiana Bueno post (in portugues, but you'll understand) to configure your Postfix server using Ubuntu.
Your first domain hosting
Let's host the mycompany.com domain.
In your Rackspace Cloud Panel, go to Hosting >> Cloud Servers >> server.mydomain.com. On the top of page click "DNS" and under "Domain Management" click "Add". You'll add a new domain.
Fill with mycompany.com and click OK. Your domain will appear in domain grid. Click the domain mycompany.com and you'll se the DNS records of your domain.
I strongly recommend you to use the Rackspace's DNS records. I tried to install my own DNS Server (Bind) and had a lot of problems. It's not a simple configuration and you have a lot of steps that does not matter.
First, let's create basics DNS records. Let's tell the Rackspace DNS server that the mycompany.com domain is hosted by your IP address.
- Type: A
- Name: mycompany.com
- Content (IP address): 12.34.567.89
- TTL (Seconds): 300
After, to ensure access using www.mycompany.com let's create a CNAME record.
- Type: CNAME
- Name: www.mycompany.com
- Content: mycompany.com
- TTL: 300
Creating the user, uploading a sample website file and creating a Apache Virtual Host
Creating a new user
Open for the first time your Webmin app. Type https://12.34.567.89:10000 in your browser. Fill username as root and your root user password.
On left side click System >> Users and Groups. Click Create a new user. PS: Creating a new user we'll create automatically a FTP account with the username and password provided.
Fill these fields:
- Username: mycompany
- User ID: Automatic
- Real Name: My Company
- Home directory: Automatic (Webmin will create the /home/mycompany path for you)
- Shell: /bin/sh
- Password: Normal password
- ... let next fields as default
- On "Group Membership" fieldset click "New group with same name as user" (user mycompany and group mycompany)
- ... next fields are ok...
- Click "Create" button
Now we have the /home/mycompany directory. Let's create a public_html directory inside it (will be our public directory, with website contents).
cd /home/mycompany mkdir public_html
A test file
Now create (or upload using FTP) a index.php file with this content:
<?php echo 'mycompany.com is working'; ?>
Creating a Virtual Host in Apache
Now we know that Rackspace's DNS servers knows the domain mycompany.com is hosted in our IP address (at Rackspace's Panel) and the website (index.php) is ok too. So, you can have a lot of domains in the same server. For that you must use Apache's Virtual Host, that tell where is the files for THAT domain you want. We can get something like:
**mycompany.com >> **/home/mycompay/public_html
**yourcompany.com >> **/home/yourcompany/public_html
Let's create a Virtual Host.
Using WEBMIN, click Servers >> Apache Webserver. Click now Create virtual host. Fill only the fields above (for others fields use the default option):
- Document Root: /home/mycompany/public_html
- Server Name: Other, type mycompany.com
- Click "Create Now"
Now click on the Virtual Server link you created to open it's configurations. Click Networking and Addresses and fill the Alternate virtual server names field with www.mycompany.com. This will allow people to access your site using both mycompany.com and www.mycompany.com.
Click Apply Changes (top/right) to restart the Apache server and apply our new configurations.
Ok! It's all configured. Now update your DNS record at your registrar (like GoDaddy, Enom, etc) and wait for the DNS propagation. Rackspace uses these DNS domains: dns1.stabletransit.com and dns2.stabletransit.com.
Remember! Using a VPS you can install and manage what you want. You can test frameworks, databases, etc. I suggest you to browse Webmin. It has a lot of usefull options like database creation, PHP configuration, Apache configuration, and what you want. It's a very powerfull tool.