Unless you are a web hosting company, that sells hosting for single domain accounts and reseller accounts with multiple users accessing your server, you do not need a control panel. If you run a huge number of websites or a massive resource consuming script that needs a vps or a dedicated server, I don’t really think that you should spend $25 a month on a control panel. Working from shell is a lot easier than working with control panels once you get the hang of it.
I have always loved Linux servers. They are stable and are rock steady, and are not buggy like Windows. And, all, they are not prone to viruses. Managing them is quite easy once you step out of the windows circle and get a hang of Linux.
And for the past 2 years, I have been using Ubuntu for my desktop too. I have never gone back to Windows again. When I am so desperate to run a windows application that doesn’t have a Linux equivalent, I use Wine. This has really annoyed me. How have I abandoned windows for so long? It has helped me operate my computer for several years untill 2 years ago. This has made me install windows again, and there is no single time that I have used it for more than 24 hours and rolled back to ubuntu. I would either get the Blue Screen of death, or some driver wouldn’t install properly, or something or the other would piss me off. People who are used to working in Windows will look at these as common problems and would say that wasting time on tweaking such stupid errors are included in the process of the installation of the motherfucking proprietary operating system. Well, there are two ways to look at anything, and it is hard to tell which is right and which is wrong. The terrorists say that terrorism is right, and the rest of the world says its wrong. Microsoft and its users say Windows rocks, and the rest of us say Windows Sucks.
Well, thats besides the point. I love linux servers. And so do 85% of the world’s server users. Not many like Windows servers. It can’t handle too many emails, it can’t handle too many dns requests and it can’t serve a website to too many people at the same time, or handle multiple processes. If you stress a windows server too much, it will just hang in there refusing to work any further. Therefore to reduce the load on a Windows server, you will need parallel servers. If you do too much of mailing, you will need a big bunch of mail servers to work in parallel, and the same goes for DNS as well. And for each server that you add additionally, you have to pay a license fee for the operating system, and a license fee for the virus scanner that you will have to install in each and every one of the servers on which you run Windows. Then there is the firewall. It is far easier to hack a Windows server than a Linux server. I have seen a funny picture somewhere in the past that shows a house with a really short boundary wall, no higher than your ankle, and a huge thick wrought iron gate. So thats windows for everyone. Linux doesn’t have any of these problems. People often don’t go for linux just because they do not know much about it, but it is not an operating system to be ignored just because you are too lazy to learn and step out of the satanic inversions of Windows. Unix used a forward slash while windows use a backward slash to start with.
So if you have a server application that runs on a linux based scripting language like PHP or perl or python, and if it is consuming enough resources that your shared hosting provider is asking you to move your script away, you will need a Linux virtual private server or a dedicated server.
VPSes and Dedicated servers are available in various shapes and sizes from many datacenters across the world. Pick the one that is suitable for you, and ask them to install ubuntu 8.10 LTS on it. I am an ubuntu guy, and have moved away from CentOS and RedHat recently in the server platforms too after the releast of Ubuntu 8.10 server edition. If you prefer some other distro, the steps that I am going to explain below should match your requirements too, with a slight change in the commands and paths to suit your distro here and there. I would be talking about ubuntu here.
I have tried almost all domain registrars in the world and I should say that Directi is the best of them all. Public Doamin Registry and Answerable.com. They offer free DNS for your domains or any product that you buy from them. None of the other add on package that they sell is over priced, and they don’t force packages on you while you register or renew a domain and checkout like godaddy does. Directi doesn’t advertise much, and if I didn’t know better, I would have thought that it is a charitable organization or something.
If you get domains from them and use their free dns service, setting up your domain without a control panel will be far easier.
Once you get your server, you will need to secure it first. The first step would be to change your SSH Port. The port by default is set to 22, and you can change it to anything between 2048 and 65536. Just make sure that you remember the port once you change it, because once the port is changed, there is no other way to get into the SSH of a server. If you forget the port, all your doors will be locked.
Putty is the shell client for Windows. It is available for Linux as well, but if you are using linux for your desktop, you could better be using a terminal.
To login to your server,
ssh root@yourserverip
Once you get into the server, check the repository list. You do not need to know much about repositories. If the repository list has got a lot of text and links to ubuntu.com and not to your datacenter’s domains, then it is fine. Some datacneters install operating systems from hard drive images and they keep their own repositories that are often un-updated to save bandwidth. If you think you have your datacenter’s repository, well, I shall update mine in a while.
To check your repositories,
vi /etc/apt/sources.list
Once you are finished checking, type in :q and hit enter, and you will leave vi. Do not hit any other key on the keyboard, especially I, unless u know what you are doing.
Once you are sure about your repositories,
apt-get update
This will update your repositories and you are ready now to install software from the repositories.
First you need to install nano. Though there is vi and vim, nano is easier to work with when it comes to editing files without mistakes.
To install nano from the repository,
apt-get nano
Once this is finished, you have an editor.
We were about to change the SSH port of the server. We will do that now.
To change your SSH Port
nano /etc/ssh/sshd_config
In the editor, you will see
#Port 22
Change port 22 to any number between 2048 to 65536. And remember this number for ever, unless you want to spend another $25 and have you datacenter reload the OS for you.
Once you alter the port, you need to reload ssh. You do that with
/etc/init.d/ssh reload
If you have filled in an invalid port number, something like 99999 or something, it will throw an error. And if it is under 65536, it will just say OK.
Once the port is set, write out and exit nano, and exit from your shell. Type exit on your shell and login again. The next time you login you will need to set the port as well. If you are using putty, enter the new port number in the appropriate field, and if you are using the linux terminal, use the following line.
ssh -p 2995 root@yourserverip
replace 2995 with your actual port number. If you get an error saying Invalid port or Connection refused, call your Datacenter and order a reload immediately so that we dont waste time.
If you managed to login successfully, read ahead, or if you had to reload your OS, repeat the above steps correctly untill you manage to login.
Once you login, you need to add a new user. If you do not add a new user, and if you think you can run your sites under the user root, a hacker will come along and upload a hacking script and wipe out your entire hard disk and carry all the data away. You should create a user with very limited previlleges that would be required to run a site. If you had a control panel, this is exactly what it does. It creates a new user for each and every domain, so that the files remain completely isolated from one another’s.
To add a new user
useradd -d /home/username -m username
passwd username
use passwd to set password for the new user.
If you wish to delete this user in the future just replace adduser with deluser in the above command.
Once you have added the user, install apache
To Install Apache
apt-get install apache2
then
MySql
apt-get install mysql-server
then
phpMyAdmin
apt-get install phpmyadmin
For mailing, I guess exim is the simplest of them all.
so,
Install Exim4
apt-get install exim4
You might also want to install ftp to upload files, but I would recommend that you connect with the user that you have created with the port that you set through sftp or ftp over ssh. Almost all ftp clients support sftp as well.
These are the basic installations that you will need to do on your server. After this you can install php, python and anything you like in the similar ways as above.
Next, you will have to host your websites on the server. Like everywhere else, there are two ways to do this. The easy way, and the hard way. Let me explain the easy way first.
The easy way:
You have created a username, lets say ravi, and a folder for the user under home. You can set that as your default folder for hosting sites, and you can add folders under ravi logged in as ravi from shell or sftp. Upload your files into the respective folders and buy domain redirection from answerable.com. Let’s say your server’s hostname is ubuntu.server.com, and you have uploaded a wordpress blog, you will need to redirect your domain to ubuntu.server.com/wordpress. Your domain will be masked and you will see only the domain name in the address bar and nothing else. This is the easy way. Domain redirection costs around $1 a year at answerable, and if you get it from resellerclub.com it costs $0.15. You can always explore the web to find out if youwould get domain redirection for less.
nano /etc/apache2/sites-available/default
You will see
NameVirtualHost *
ServerAdmin webmaster@localhost
DocumentRoot /var/www
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
In this, change /var/www to /home/foldername. I created a new user called ubuntu, so the foldername is ubuntu. Mind the /. No trailing / in the first change and there is one in the 2nd.
NameVirtualHost *
ServerAdmin webmaster@localhost
DocumentRoot /home/ubuntu
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
If you do not wish to waste money on domain forwarder, well, certainly I wouldn’t, you can do it the hard way. It is not exactly hard. Once you create a few domains this way, it will only be as tough as creating a hosting account on cPanel. Every site has its own file like the default file. So all you need to do is to create a new file for each site by copying default, and adding just one line ServerName yourdomain.com in it and setting the path accordingly.
so, lets say you are creating 3 sites, that is ubuntu804.dyndns.com, ubuntu810.dyndns.com, ubuntu904.dyndns.com. For these three sites, you willhave to create 3 separate files. You do this with
cd /etc/apache2/sites-available
cp default ubuntu804.dyndns.com
cp default ubuntu810.dyndns.com
cp default ubuntu904.dyndns.com
Once done with this, you will find 4 files in the sites-available directory including default.
Now edit the files one by one. Start with ubuntu804
nano ubuntu804.dyndns.com
You will see
NameVirtualHost *
ServerAdmin webmaster@localhost
DocumentRoot /var/www
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Edit /var/www/ the path as required. Mind the trailing / in both instances. Then under ServerAdmin, add a new line with ServerName ubuntu804.dyndns.com. The changes should now look like
NameVirtualHost *
ServerAdmin webmaster@localhost
ServerName ubuntu804.dyndns.com
DocumentRoot /home/ubuntu804
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Similarly make changes as required for the other two files as well.
Once this is done, you need to let apache know that you have created 2 more sites and make it serve them too. Luckily, unlike any other Linux distro, ubuntu has got a set of simple commands to get apache to do this for you.
All you need to do is pass the name of the file that you have created for a new domain to a2ensite
a2ensite ubuntu804.dyndns.com
a2ensite ubuntu810.dyndns.com
a2ensite ubuntu904.dyndns.com
Once done, you need to restart apache
/etc/init.d/apache2 restart
After apache is restarted successfully, if your dns is configured correctly, your sites should work from the respective folders on the server.
Databases
You have phpMyAdmin to create and manage databases on mysql. you can access that from
yourservername/phpmyadmin
Your scripts can send mails as localhost through exim. in your DNS zone, you can just add MX records of google apps which gives you free email boxes for your domain names. Creating, configuring and using pop3 and imap on a server is an entirely different thing and I guess I will have to make a post on that seperately.
If you had the patience to read till this line, do leave your queries and comments below.