This is the ultimate guide how to build, setup and config Ubuntu-based unmanaged web server on VPS or Dedicated servers. Very complete tutorials for newbie. Finally I feel all the tutorials are completed and ready for you to build your own very first production web server on Ubuntu. My goal writing this blog is to guiding newbies who were afraid to switch from Shared hosting environment to unmanaged Virtual Private Server (VPS) or even Dedicated ones so they can now build a working live server to host their websites, forums and blogs in it.
Many newbies are still having a perception that purchasing a VPS plan is quite expensive because a user has to pay for cPanel license and managed service provided by the vendor. For your information, not all VPS are pricy. Most common unmanaged servers are much cheaper than managed ones. So here’s I write all necessary steps to build your own so you can simply throw away your fear.
My last hope, you have to be more than capable and brave to start your first step to build a production server to host your websites without having to purchase management service for your tiny little server. At least, I hope by reading this ultimate guide can be your first step to learn more advanced method to manage and secure your server.
Before you proceed, these are basic skills you have to master or at least know part of it:
– How to use Putty (Windows) – Mac and Linux use Terminal
– Most popular and common commands use in SSH-ing a server
Basic Guides
1. Basic Ubuntu Setup Before Building A Working Server
This article shows you most common practice and essential setup to build Ubuntu web server.
2. How to Install a Web Server, PHP5 and MySQL on Ubuntu
2.a How to Install LAMP Stack
LAMP stands for Linux, Apache, MySQL and PHP. Ubuntu itself is a Linux. So what you gonna need are:
– How to install Apache web server and PHP5
– How to install MySQL database server
2.b How to Install LNMP / LEMP Stack
LNMP stands for Linux, Nginx, MySQL and PHP. Sometimes it also called LEMP which stands for Linux, Engine X, MySQL and PHP. Ubuntu itself is a Linux. So what you gonna need are:
– How to install Nginx web server and PHP5
– How to install MySQL database server
Necessary read:
– Top Most Common Basic MySQL Commands
2.c How to Automatically Install LAMP or LNMP stack (your choice)
This method is faster way than above manual methods but not so recommended if you want to learn more. Because everything is automatic, this could be your solution if you wish to build a server in a snap.
– Easiest Way To Install LAMP and LNMP Stack On Ubuntu
More To Do With Your Server
1. Install A Mail Server
A mail server is necessary for your site to be able to send emails like confirmation, login credentials, etc. For that purpose Postfix is the perfect choice.
– Easy Way To Install Postfix On Ubuntu Server
2. Connecting Your Domain To Server
Once you setup your server, you may also need to connect your domain so it can resolve to your server. This is basically can be done via DNS Manager provided by your Registrar. Big company like GoDaddy and NameCheap provide that feature. Alternatively, if you wish your domain has its own Name Server like ns1.domain.com and ns2.domain.com, read my guide about installing BIND DNS server:
– How To Install and Setup Bind9 On Ubuntu Server
3. Uploading Files to Server
Since the server has no cPanel or any other Control Panel software installed, so you won’t find any File Manager. All files upload and management tasks can be done via FTP:
– Using SFTP To Upload and Manage Files On Your Server
Setting Up Your Site Into Server
If you are familiar enough with cPanel (or any similar panels), to add new website in it you can simply use the Addon Domain function or if in WHM you can simply create new cPanel account for each new site. But the case is really different in a server without cPanel. For that read:
1. Add New Site To Apache-based Server
This tutorial will guide you how to add new site and domain to your Ubuntu server with Apache and PHP5. That includes how to add Apache virtual hosts file.
– How To Add New Website On LAMP Server
1.1. How To Install WordPress on Apache
– How To Install WordPress On Apache-based Ubuntu Server
2. Add New Site To Nginx-based Server
– How To Add New Site Into Your Nginx-based Ubuntu Server
2.1. How to Install WordPress on Nginx
– How To Install New WordPress Blogging Script On A Nginx-based Ubuntu Server
2.2. Nginx Virtual Hosts Config for W3 Total Cache Plugin
– How to Setup Nginx Virtual Host For WordPress With W3 Total Cache
2.3. Nginx Virtual Hosts File Config for WP Super Cache Plugin
– How to Setup Nginx Virtual Host For WordPress With WP Super Cache
3. Website Migration: cPanel to Server
Instead of creating your new site from scratch on your server, you can simply move your production site from cPanel (shared hosting) to the new server you build. I posted a nice easy-to-understand tutorial how to fast moving your site. This guide will show you how to move or migrate a website from cPanel to the unmanaged server you’ve setup. The word “Server” here refers to either VPS or Dedicated server.
– How To Move Website From cPanel-based Hosting To Your Server
Basic Security
1. Restrict Number of Simultaneous Connections Allowed
This guide will show you how to limit the number of maximum connections coming from a single IP to your server to avoid traffic flooding. This way you can restrict the number of maximum connections allowed for a single IP to your server via port 80 (default http port).
– How To Limit Maximum Connections In Your Server
2. Avoid Brute Force Attack with Fail2Ban
In this tutorial I’ll try to explain necessary steps how to install Fail2ban and some basic configurations. Once detected a brute force attempt, Fail2ban will simply update firewall rules to reject the IP address automatically and lock that IP from your server for defined amount of times.- How To Install Fail2Ban To Protect Server From Brute Force SSH Login Attempts
More With Ubuntu Server (Advance)
1. Install, Setup and Configure Varnish Cache with Apache
This tutorial will tell you how to install Varnish Cache 3 HTTP accelerator and configure it to run with Apache 2 on Ubuntu server.
– Install Varnish 3 To Run With Apache 2 On Ubuntu Server
2. Install, Setup and Configure Varnish Cache with Nginx
Running Varnish in front of Nginx is not really suggested by official Varnish Dev Team because Nginx is already more than capable for handling static files. But however every body has its owned flavor and preference, so the decision is up to you. So if you decided to test how Varnish and Nginx can boost your server performance, simply read my guide:
– Install Varnish 3 To Run With Nginx On Ubuntu Server
Shortcut / Quick Method
1. Complete Nginx Stack Installation Under 15 minutes with EasyEngine
Installing the whole package of LNMP/LEMP stack would be painful for non adventurous. Alternatively, EasyEngine comes in handy to install Nginx, PHP5-fpm (with OPCache), MYSQL database server, Postfix mail server, PhpMyadmin and WordPress.
– Quick Install LNMP Stack Using EasyEngine
This page served as an Index to all my previous tutorial. I compile all of those articles related to Ubuntu-bsaed server setup here in this page. I will surely update this page each time I posted another article. Have a question or need more queries? Do not hesitate to contact me or write a comment below. Enjoy and do not forget to follow ServerMom in Twitter and also catch me on Google+.
Don’t forget, if you liked this ultimate guide, donate us a one click on this +1 button (need to login to Gmail / Google account first):
Thanks, bookmarked inn my browser. The tutorial is really perfect for me 😉
Thanks you liked it
Bookmarked. Anyway which one is better, Apache + Varnish or Nginx + Varnish ? thanks..
For me, I better stick with Apache + Varnish as it makes me easy dealing with .htaccess file 🙂
Thanks in advanced. Your tut is really complete especially for beginners like me. Anyway, what server you are currently using? thanks
Hi Grace, glad you like it. You can read more info about My Playground server to find out more about it :).
Howdy! I know this is kind of off topic but I was wondering which blog platform are you using for this website?
I’m getting sick and tired of WordPress because I’ve had
issues with hackers and I’m looking at options for another platform. I would be great if you could point me in the direction of a good platform.
Obviously this is WordPress. 🙂
Which is better, Ubuntu + LAMP or CentOS + LAMP? Thanks
Hi Andrew, I think both are good. But it depends on how familiar are you with CentOS or Ubuntu 🙂
It is in reality a nice and useful piece of information. I’m happy that you simply shared this useful info with us. Please keep us up to date like this. Thank you for sharing.
I’m getting -11-system error when I try to install LNMP. I researched and a quick fix would be to switch over to google’s public DNS 8.8.8.8 or 8.8.4.4 I believe it was, question is, do I want to do that? How do I make it work from my own VPS? Thanks for help and this tutorial, love you for it.
edit /etc/resolv.conf
you can use either nano or vi editor 🙂
Hi Sawiyati
You tutorials are awesome. Thanks alot I just got a small problem I need your help with. my .htaccess files
I have got a Ubuntu Server which runs Apache2 and PHP5 and I have also installed varnish following your tutorial. Everything works fine but non of my .htaccess file are working. Especially when I want to “deny from all” within .htaccess for some directories in my web server
This is the error I get when I use “deny from all” within .htaccess I cannot see any pages.
—————————————————————————————————–
Forbidden
You don’t have permission to access /James/ on this server.
Apache/2.2.22 (Ubuntu) Server at 119.9.40.243 Port 8080
——————————————————————————————————-
I need your help what can I do? Why is it not reading my .htaccess file especially the one when I use “deny from all”
Awesome blogs mam 🙂
I too was just about to setup on digitalocean. I’m wondering if all that’s in this tutorial will be enough for a secure production site. Is this all you did to get your site up and running? Or is there more that you haven’t mentioned here. What more did you do to secure your site for production? Or is just what’s in this tutorial sufficient?
I’m wondering if all that’s in this tutorial will be enough for a secure production site?
NO
Is this all you did to get your site up and running?
Yes and No.
Or is there more that you haven’t mentioned here?
Basic setup is all it. Of course there are more you need to do for advanced setup.
What more did you do to secure your site for production?
You’ll need advanced setup and advanced security system like purchasing custom DDOS-filtered IP, etc.
Or is just what’s in this tutorial sufficient?
Basic setup yes. Need advanced ones? NO
I hope you will do a guide on “How to secure your server for production”, detailing all the things needed to be done as you have mentioned in you answer to the last answer to Kristian, like “purchasing custom DDOS-filtered IP etc. It will be really helpful just as you basic setup guides are.
Hi Sawiyati,
Great Site. I’ve setup my server reading your tutorial.
I have a question though, I’ve completed my server using centos LAMP, whenever I point my browser though to my domain (used bind9), I cannot access it?
Thank You,
me2
It should be your BIND config or your domain setting like have you setup/register NS1 and NS2 in your registrar
Hi Sawiyati,
Thank You for your reply.
You’re really good.
I will check my domain setting.
Thank You,
me2
Hello, you are the best! Thank you for posting this topic online. I am a newbie and have been searching the net for 3 days to help set up my VPS. I accidentally clicked your site on Google and viola, here it is – all in one place! Thanks will definitely recommend your site!
Hey – This is amazing. Thank you for pulling all of this work together. I find it very helpful 🙂
I’m working on establishing a wordpress/Ubuntu/ Blog – I would also like to setup a mail server to handle all of my mail for less then 3 boxes.
My question for you – is do you have any suggestions or changes as of May -2015? Anything that I should be considering that isn’t represented in the excellent reporting above?
Thanks again!
Nothing major, you can read my new tutorial here while email you can simply use Zoho or any other thirdparty mail server for advanced security.
I currently have about 25 sites on a VPS… None with any major traffic. All WordPress based sites. If I had my own server, how many sites can you usually put on it? I guess it depends on the computer used, the bandwidth of my ISP and disk space?
It depends on the traffic each site has and how complex are the themes and plugins being used
Thanks, your guide has actually made it easier to switch from Windows 7/8/X to Mint/Ubuntu found you through Flipboard
Alhamdulillahi,
Meniko estu paring manfaat
Nuwun
Hats off to you. You solved many of my problems within single click ;). I am tired of my hosting provider and now i setup my own with your help.
Peace