Roshan Book

My Tech Notebook

My favorite web server setup, Ubuntu Server, LAMP, Webmin, and Virtualmin.


Source:http://www.patrickjwaters.com/blog/2011-07-13/my-favorite-web-server-setup-ubuntu-server-lamp-webmin-and-virtualmin/3524

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 ‘passed’ 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.

3 responses to “My favorite web server setup, Ubuntu Server, LAMP, Webmin, and Virtualmin.

  1. tom brady jersey February 15, 2012 at 4:25 pm

    Among the finest to tell a person that i’m just brand new to blogging and certainly liked you are website. Most likely I will bookmark your site . You possess outstanding articles. Kudos for discussing with us your site.

  2. mathias May 28, 2012 at 8:05 pm

    Just an advice; first thing you should do after installing webmin is: change the default port from 10000 to w.e you like, . (Webmin=> Webmin Configuration=>Ports and adresses=>the 10000 port should be on the right side. Change it. (cant be over 10000)
    Another thing you should do is, if you dont plan to acces your console remotely, or if you want to be a bit more secure or if you want to prevent the bad guys trying to acces your server, then go to: Webmin Configuration: IP acces control=>check “only allow from selected addresses” then type the allowed addresses in the box below.
    Remember, NEVER use default configs. Hope this helps.

  3. Lukas July 26, 2012 at 11:04 pm

    As an FYI, I had trouble with this method and on the Virtualmin forums they suggested using the install script instead: http://www.virtualmin.com/node/22860

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: