The approximate minimum requirement for your server/VPS is around 256MB of RAM. MySQL will use the most memory. It uses around 300MB of RAM on my personal VPS.

NOTE: If you're getting an "cannot connect to mysql.sock" error, that means that MySQL is not running.

As I've stated this guide is for the Debian distribution of Linux. So that is another requirement. At current this guide isn't going to contain instructions for basic installation of Debian, but eventually I might add it.

// 1.3 Starting Out

I've broken this part into 2 sections: one for people who have decided to purchase a server from an online company for their hosting and one for people who decided to use one of their old PCs as a server.

'Online' Server

If you're running a Windows OS, I'd suggest you download an application called PuTTY. This allows you to connect to your machine via SSH (Secured Shell). You can do this because most hosts (the company providing your server) will have your server already somewhat pre-setup. How much is has been set up, depends on the host. This guide assumes that the host hasn't pre-setup most things. What PuTTY is allowing you to do is connect to your server and manipulate it via the "command line" or terminal as it's known on Linux systems. This is how you're going to do EVERYTHING on your server. Your host will probably email you your SSH details or it will be available for you once you login their website.

'Own' server

Read through the 'Online' Server section above. You can also use an SSH but only once you've installed and setup an SSHD on your server. You have the advantage that you don't need to SSH to your server, since it's in your own home, but if you don't feel like running to the computer or don't want to use a monitor for your server, it is advised that you do install an SSHD so you can control your server from your other computers. When connecting to your server you will most likely SSH to the local IP address of the server and not it's physical IP address (since all your computers share the same physical IP address). You will also have to go about setting your router to forward incoming traffic on port 80 to your server. This can be done multiple ways, see http://www.portforward.com/ if you really need help, but this should all be common knowledge and you should understand port forwarding.

The following section will be written mostly in the context for those who have purchased their server from an online host. I will update this section and make it larger when I have some more time to make things clearer for those who want to use this method.

2.0 Getting to Work

// 2.1 First Thing's First

Log in by whatever method (probably SSH) to the root account. PuTTY is pretty straightforward to use. If you're running Linux, use the ssh command in the terminal (ssh ServerIPHere -p ServerPortHere -l ServerLoginNameHere). The IP address is the IP address of your server, the port is usually 22 (I set my to something different once I've set everything up to keep my server safer), and the login name will be root.

In my experience sometimes hosts (like 1and1) do some stupid things. So I recommend checking a couple of things before starting.

First find out what version of Debian you're using. Type:

Code:

cat /etc/issue

You should get a response like:

Code:

Debian GNU/Linux 5.0 \
\\

5.0 is called Lenny and 4.0 is called Etch (Below explains upgrading if you have to).

Next we're going to check what repositories you're using (where your system will default to download software).
Type this in the terminal

If yours says "etch" instead of "lenny" don't worry, that just means your running Debian 4 and not Debian 5. It's really simple to upgrade. To upgrade from Etch to Lenny see this page: http://www.go2linux.org/upgrading-debian (You may have to install aptitude by typing "sudo apt-get install aptitude". Aptitude are basically synonyms.)
If your's looks completely different (some hosts *cough*1and1*cough* use their own repositories and it's extremely stupid) type:

Code:

vi /etc/apt/sources.list

You're now using the program "vi" to edit this file. To use vi you must press the "i" key on your keyboard to go into insert mode. Then you can delete everything inside and paste the correct contents into your file. To save and exit, hit the "Esc" key on your keyboard and then type ":wq!" and hit
"Enter". Vi is a little confusing at first, but once you learn it is as a very valuable text editor. Once we've got things updated, I'll run you through installing "nano" a much easier text editor.

// 2.2 Upgrading & Installing Common Software

Now we're going to upgrade the entire system. This may take a couple minutes.

Code:

apt-get update

That updates the repositories. Now to upgrade the system itself:

Code:

apt-get upgrade

NOTE: If you are receiving errors regarding resolving see the "BIND9" section below.

About halfway throught upgrading, it should ask you if you want to sync clocks with the Debian servers. I'd suggest this.

Now to install a few common applications that are very helpful: (Some might already be there)

Now we should reboot so all processes are updated with the new hostname:

Code:

shutdown -r now

You'll be disconnected if you were using SSH, once the server is back online, you should be able to reconnect and continue where you left off.

*Bind9
Bind9 is what resolves everything on your server. Some VPSs might not require Bind9, because the host server is already resolving things. If you couldn't update previously or have gotten any errors regarding resolving, this will most likely solve the problem.

Install:

Code:

apt-get install bind9

Now stop Bind9:

Code:

/etc/init.d/bind9 stop

Just for some more security we're going to set BIND9 to run chrooted and set as the user 'bind' which doesn't have as many priviledges as root.

Although, most of you won't be using Ruby, there is a small problem with it. Basically it'll prompt you to download .rb files unless you do this:

Code:

nano /etc/mime.types

and comment out

Code:

application/x-ruby rb

so it looks like

Code:

#application/x-ruby rb

Then restart apache (again)

Code:

/etc/init.d/apache2 restart

ProFTPd

Install Proftpd:

Code:

apt-get install proftpd

Select to run it standalone.

Simple as that.

3.0 Ease of Use

Coming soon...
In this section I will give details on some popular software that just helps manage things way easier. This will include things like phpmyadmin, webmin, and firewalls like apf & csf.

4.0 Configurations

Coming soon...
In this section I will cover some of the configurations that are popular and secure for a lot of the popular programs that people are running on their webservers.

5.0 Conclusion

When it comes down to it, majority of the internet is running on linux servers. The top choices for server distrubutions are CentOS and Debian. This guide was made to help kick start your learning experience running your new webserver off of one of the most preffered mediums (and for good reason). This server has the advantage of being lite and only having what is absolutely needed. This is how I've been running my webservers for years and I hope this helps someone out there learn just as I did.

// 5.1 Credits

-Myself for putting together the guide
-A couple guides that reminded me of a few things
-Debian CommunityEdited by Jimi - 5/15/10 at 8:42pm

First, if you get an error about mysql.sock, it usually means the MySQL server isn't actually started. Just start it up and you should be fine. You might also mention how to use update-rc.d to ensure that a service starts at boot time.

Second, after setting the hostname, you should restart the server so that all processes pick up the change, because it only applies to processes that start after the change is made.

You could add a section about setting the timezone. (And remember to restart after changing the timezone.)

Finally, I don't trust Debian and distributions based on it, especially not for servers, and especially since Debian still has a critical data-loss bug (also affects Ubuntu) which ate 400GB of my data and has remained unfixed for months. All of my servers run Red Hat-based distributions, usually CentOS, but I have one Fedora server. The reason is that Red Hat specializes in building an enterprise-grade Linux distribution, and I refuse to accept anything but the best.

First, if you get an error about mysql.sock, it usually means the MySQL server isn't actually started. Just start it up and you should be fine. You might also mention how to use update-rc.d to ensure that a service starts at boot time.

Second, after setting the hostname, you should restart the server so that all processes pick up the change, because it only applies to processes that start after the change is made.

You could add a section about setting the timezone. (And remember to restart after changing the timezone.)

Finally, I don't trust Debian and distributions based on it, especially not for servers, and especially since Debian still has a critical data-loss bug (also affects Ubuntu) which ate 400GB of my data and has remained unfixed for months. All of my servers run Red Hat-based distributions, usually CentOS, but I have one Fedora server. The reason is that Red Hat specializes in building an enterprise-grade Linux distribution, and I refuse to accept anything but the best.

Thanks for heads up I'll add more on those topics.

As for the whole Red Hat vs Debian server-wise. I'm not really a fan of Red Hat distributions and I've never ran into this data-loss bug. I'll be sure to look into it though.