My favorite web server setup, Ubuntu Server, LAMP, Webmin, and Virtualmin.
patrick — Wed, 07/13/2011 - 20:33
Over the past few years I have experimented with different web server setups. I have found that the combination Ubuntu, LAMP (Linux, Apache, Mysql, and PHP), Webmin, and finally Virtualmin provide many advantages in my day to day workflow as a web developer. This setup provides me with an easy to use and easy to maintain web server that lessens the time spent configuring the server and increases my time programming. Here are my step by step instructions for setting up my favorite server configuration.
Step 1: Install Ubuntu Server
Download and install Ubuntu Server edition. At the time of writing this 11.04 was the most current version. I prefer to use the most Current LTS release, so I will choose 10.04 for my install. When installing Ubuntu you can choose to install the LAMP stack if you wish and skip step 2. Just as a side note, the first time I set this up was on Ubuntu 8.04 and the steps have not really changed sense.
Step 2: Install LAMP
First change to the root user by typing the following and entering your password.
patrick@ubuntu:~$ sudo su
Then to install the LAMP package type the following
root@ubuntu:/# tasksel
This will prompt you with a screen like the this

Use the the arrow keys to highlight the LAMP Package and press space bar. Next hit tab to jump to the ok button and press enter.
During this process you will be prompted to enter a root mysql password. I recommend choosing a mysql root password different than your current root/user password. That is pretty much it for installing LAMP.
Step 4: Installing Webmin
Next we are going to install webmin. Webmin is a free peace of software that give you a web based interface for controlling different parts of your server. For example, if you wanted to change some php settings, you don't have to ssh into the server and edit you php.ini. You can do it all through webmin. I am not going to give a thorough tutorial on webmin, but I do recommend poking around in it, once it's installed.
So first step to installing webmin is adding it's repo's to the ubuntu. It doesn't come in the prepackaged repos. So you are going to want to edit the file /etc/apt/source.list like so.
root@ubuntu:/# nano /etc/apt/sources.list
This will open a simple text editor. Use the arrow keys to get to the bottom of the file and add the following lines
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Then hit cntrl-x and they y and then enter, to save the file.
Next run the following
root@ubuntu:/# cd /root/
root@ubuntu:~# wget http://www.webmin.com/jcameron-key.asc
root@ubuntu:~# apt-key add jcameron-key.asc
root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get install webmin
This will now install webmin to your server. Once webmin is installed you can access it at https://YOUR.IP.ADDRESS:10000 (ex. https://192.168.1.100:10000) take note of the https. You will probably get a warning about the certificate note being trusted, this is ok. This happen because your https certificate is not signed by a company like veri-sign. Now go the that url and you should get a screen like so

You are going to now login with your root user and password. Note that Ubuntu does not set a password for the root user by default. You can do that by changging to the root user and typing 'passwd' and setting your password.
Once you log in you will get a screen like so

You have no successfully installed webmin! Click around there a lot of awesome features!
Step 5: Install Virtualmin
Next we are going to install a webmin module called Virtualmin. Virtualmin is a module that turns your server into a multi domain hosting platform. It organizes your websites files and folders automatically. It does a whole bunch of configuration automatically for you, like creates the necessary apache host files, creates a mysql database, and creates a linux user with ssh access. This is the module that I use the most. I rarely need to ssh into the server to mess with configuration. I can setup websites in seconds, it's a big time saver. So here is how you install Virtualmin. I have to admit the first time I installed it, it was a bit tricky, but I have done it so many times now, that I know all of the gotcha's and I hope this will make the process smooth for others as well.
Alright so you need to be logged into webmin and at the home screen. You will need to go and click on and expand 'wbemin' in top left hand corner and then click on 'Webmin Configuration' like so.

Next click on the 'Webmin Module'

Now go to this link http://www.webmin.com/vdownload.html and look for the 'Webmin Module Format' link. It will be a link that looks like this, but the version may have changed http://download.webmin.com/download/virtualmin/virtual-server-3.87.gpl.wbm.gz.
Once you have that link you are going to want to go back to the webmin configuration page you were at before and check the radio button labeled 'From ftp or http URL' and paste the link in the corresponding text field and click 'Install Module'.

Step 6: Configure Virtualmin
Virtualmin is now installed but needs to be configured. First we need to install apache2-suexec-custom. You need this so virtualmin can change apache's default directory to /home
root@ubuntu:~# apt-get install apache2-suexec-custom
root@ubuntu:~# cd /etc/apache2/suexec
root@ubuntu:/etc/apache2/suexec# nano www-data
replace the line "/var/www" with "/home" (without "" ). hit control-x then y then enter
root@ubuntu:/etc/apache2/suexec# apache2ctl restart
Next we need to set the MySQL root password in webmin. if you click on Servers > MySQL Database Server on the left hand side and enter 'root' for the login and your mysql password. Remember this is not your linux password, it's your mysql password that you set when installing LAMP.

Next we need to turn on some apache modules. Goto to Servers > Apache Webserver. You will see a 3 tabs click on 'Global configuration' and then lastly click on 'Configure Apache Module'. Now you are going to want to make sure you check 'actions', 'suexec', and 'rewrite' and click 'Enabled Selected Modules'.

Next you are going to want to click on Servers > Virtualmin Virtual Servers (GPL). This will take you to a Post Installation Wizard. You do not want to run through the wizard. You are going to want to push cancel. This will take you to a screen like so and you are going to want to push 'Manage Enabled Features and Plugins'

Next we are going to turn OFF some features of Virtualmin. I have found that I only use a few key features and other features require further configuration. Uncheck 'BIND DNS domain', 'Mail for domain', and 'Webalizer reporting'.

Finally click save and you will be taken to the new Vitualmin Configuration screen. You have now successfully installed Virtualmin!
Step 7: Setting up a website with Virtualmin
The next thing to do is add a new website/virtual server with virtualmin. Navigate to Server > Virtualmin Virtual Server (GPL). Next look for a button that says 'Add New Virtual Server Owned By:' and click that.

This will bring you to a new screen with a form. Enter in the domain you want to host on your server, without the www, and enter an administrator password. This is all that is required, you can thumb through the other options, but you do not need to change anything else. Once you have the form filled out click 'Create Server;.

When you clicked create server Virtualmin did the following
-Created a new linux user on your server that you use to ssh and sftp into.
-Created a mysql database named the same as your domain without the '.com' or '.org' etc. For example if the domain you created was test.com, then Virtualmin would create a database called 'test'.
-Created a new folder structure on the server. For example if you created test.com, you can navigate to /home/test/. Here you will find a folder called 'public_html'. This is your web root folder.
Well thats it, let me know if you find any errors in my tutorial so I can correct them. I hope my tutorial help shed some light on a decent web server setup.
patrick's tweets
- Recent Project: Converting the BMJ (British Medical Journal) to Drupal http://t.co/6sTLhMFZ — 1 year 9 hours ago
- Climate Change http://t.co/wuPwyIan — 1 year 21 weeks ago
Thank you!
Anonymous — Thu, 07/28/2011 - 15:45I really have to second this!
Anonymous — Sun, 06/03/2012 - 20:08Thanks You too
Anonymous — Fri, 07/29/2011 - 08:07Hello, thanks for this tutorial
Anonymous — Mon, 08/08/2011 - 10:10You need to install BIND9 on
patrick — Mon, 08/08/2011 - 11:00You need to install BIND9 on your server. Webmin can manage bind as well. I will do a blog post on that soon hopefully,
Install BIND9
Anonymous — Sat, 12/17/2011 - 13:26hi
Anonymous — Mon, 08/08/2011 - 15:02You have two options, One is
patrick — Mon, 08/08/2011 - 15:14You have two options, One is you can create your own name servers, or you can just point the domain at the ip address. Like I said above I need to add more to this tutorial about setting up name servers. Hopefully in a week or two I will expand on it.
hello thanks for respond..
Anonymous — Mon, 08/08/2011 - 16:20You are talking mail server
patrick — Mon, 08/08/2011 - 16:23You are talking mail server configuration now, you can install postfix and webmin will allow you to controll the setting in postfix, but think you have stepped out side my confort zone. Check out this tutorial on setting a postfix mail server. http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu9.04
thank you again patrick
Anonymous — Mon, 08/08/2011 - 16:44Thankssss
Anonymous — Tue, 08/16/2011 - 02:25How to access the newly created site?
Anonymous — Wed, 09/21/2011 - 03:39access on local network
Anonymous — Thu, 03/08/2012 - 19:44Changing root password
Anonymous — Wed, 10/26/2011 - 03:11FTP access
Anonymous — Thu, 10/27/2011 - 15:42sudo apt-get install ftp
patrick — Thu, 10/27/2011 - 15:49super! what a time saver
Anonymous — Thu, 10/27/2011 - 15:55FTP access
Anonymous — Thu, 10/27/2011 - 16:45I'm pretty sure that if you
patrick — Thu, 10/27/2011 - 16:51May GOD Bless You !
Anonymous — Sat, 11/12/2011 - 23:51Just Brilliant!
Anonymous — Sat, 12/10/2011 - 02:43bingo! good advice
Anonymous — Mon, 05/07/2012 - 20:56Great Tutorial! Using CGI?
Anonymous — Wed, 12/21/2011 - 22:52Sethandler Error
Anonymous — Mon, 01/23/2012 - 20:47error
Anonymous — Tue, 02/07/2012 - 10:19:D
Anonymous — Wed, 02/08/2012 - 09:10No what?
Anonymous — Tue, 02/21/2012 - 00:43Now what
Anonymous — Tue, 02/21/2012 - 00:46Security
Anonymous — Tue, 02/21/2012 - 05:46Awesome
Anonymous — Mon, 02/27/2012 - 01:26Thank you
Anonymous — Mon, 03/05/2012 - 10:57public ip address
Anonymous — Thu, 03/08/2012 - 21:38Thank you very much
Anonymous — Fri, 03/09/2012 - 07:33Thanks...
Anonymous — Sat, 03/17/2012 - 18:47Awesome! But one error...
Anonymous — Mon, 03/19/2012 - 08:22Next
Anonymous — Mon, 03/26/2012 - 06:15Website preview
Anonymous — Wed, 03/28/2012 - 23:04Help please...
Anonymous — Thu, 03/29/2012 - 01:46Phewh..
Anonymous — Thu, 03/29/2012 - 01:51FYI on error
Anonymous — Sun, 04/01/2012 - 19:57Accessing virtual servers locally?
Anonymous — Sat, 04/14/2012 - 14:57i am having the same problem.
Anonymous — Wed, 04/25/2012 - 11:09Edit your host file
Anonymous — Fri, 05/04/2012 - 22:16Access to virtual server website
Anonymous — Mon, 05/07/2012 - 04:19Same question, what is the address to use in the web browser?
Anonymous — Sun, 06/17/2012 - 13:59Ok if you are running this
patrick — Mon, 06/18/2012 - 10:16IP address not pointing to /home/.../public_html/
Anonymous — Sun, 05/06/2012 - 22:40Accessing website at /home
Anonymous — Mon, 05/07/2012 - 04:20I wonder too...
Anonymous — Mon, 06/18/2012 - 10:10Post new comment