Linux + Xen + Webmin: a Cheaper Way to Go VPS
Total Page:16
File Type:pdf, Size:1020Kb
[Copyrights Reserved] Tony Wang http://www.shdol.com/ Linux + Xen + Webmin: a cheaper way to go VPS Author: Tony Wang 04/2007 the webmaster of these websites 1. Smart Home Decorations Online http://www.shdol.com/ 2. Everything Chinese http://www.panda-greatwall.com/ As many websites have outgrown the shared-hosting stage, webmasters want to seek more advanced hosting services. As dedicated servers are very expensive (the cost ranges from $80 - $200 USD per month), virtual private servers (VPS's) are a more economical way to meet their needs for advanced hosting services. What is VPS? Here is its definition from Google: In computing, Virtual private servers are a means of splitting a single physical server into multiple virtual servers. Virtual private servers are sometimes called virtual dedicated servers. The practice of partitioning a single server so that it appeared as multiple servers was common practice in the days of mainframe computers, but has seen a resurgence lately with the development of software such as User-mode Linux and Xen. As you can see from the above definition, VPS functions just like dedicated server at a much lower cost. You can also say VPS is like shared hosting, because a single physical server (real machine) is split into several VPS's. Linux Again, based on the definition found on Google, Linux is a free open-source operating system based on Unix. Linux was originally created by Linus Torvalds with the assistance of developers from around the globe. At present, Linux has quite a few different distributions such as Fedora Core/Red Hat, Debian, CentOS and so on. Most of these distributions are free license, which is an important reason why it is cheaper to use Linux compared to Windows. PHP, as a script language for dynamic web pages, has an enormous support community and extensions. MySQL is open source and a freely available yet full featured relational database. Running PHP and MySQL on Linux is very cost-effecient, which gains its popularity nowadays. This tutorial assumes your VPS is pre-installed with Linux OS by your service provider, so I will not dover how to install Linux on your server. You always can google what you want to know. ;) Xen The introduction to Xen below was adapted from a Xen Wikipedia article: 1 [Copyrights Reserved] Tony Wang http://www.shdol.com/ Xen is a free virtual machine monitor for IA-32, x86-64, IA-64 and PowerPC architectures. It is software that runs on a host operating system and allows one to run several guest operating systems on top of the host on the same computer hardware at the same time. Modified versions of Linux and NetBSD can be used as hosts. Several modified Unix-like systems may be employed as guest systems; since Xen version 3.0 unmodified versions of Windows and other systems can also be used as guests on certain hardware. Xen originated as a research project at the University of Cambridge, led by Ian Pratt, senior lecturer at Cambridge and founder of XenSource, Inc. This company now supports the development of the open source project and also sells enterprise versions of the software. The first public release of Xen was made available in 2003. Suppose you have a server that has a Linux Operating System and you would like several people to share as if everyone had a physical server machine. In this situation, you need virtualization of the hardwares on your real physical server so that everyone hosted can manage "theirs". With Xen, you can have multiple operating system and services running simultaneously. This is how Xen works to make VPS possible. In addition to Xen, Virtuozzo Power Panel (VZPP) and VMware also can virtualize servers. Because of the good support for commercial use, VZPP and VMware are more widely used. However, the license of Xen is GPL, which means free for use. So why pay for virtualization when there is free software available out there? Before we talk about Webmin, we would like you to set up some basic stuffs in your Linux (Fedora Core 6 in this example): 1. Install some necessary softwares through YUM that are needed later on: Log in your remote server through SSH (Putty Client), run these yum lines: • yum install fetchmail wget bzip2 unzip zip nmap openssl lynx fileutils ncftp gcc gcc-c++ • yum install quota Edit /etc/fstab and add ,usrquota,grpquota to the / partition (/dev/VolGroup00/LogVol00) To enable quota, execute the following commands: touch /aquota.user /aquota.group chmod 600 /aquota.* mount -o remount / quotacheck -avugm quotaon -avug 2. Install MySQL (5.0) Database: 2 [Copyrights Reserved] Tony Wang http://www.shdol.com/ In your Putty Client, type: yum install mysql mysql-devel mysql-server Then create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server: In Putty, type: chkconfig --levels 235 mysqld on /etc/init.d/mysqld start Restart your MySQL database server: /etc/init.d/mysqld restart To set the password for root user, otherwise anybody can access your MySQL database server: mysqladmin -u root password yourrootsqlpassword mysqladmin -h server1.example.com -u root password yourrootsqlpassword Alternatively, you can wait to install MySQL database until you have Webmin installed. We will cover this in Webmin section. 3. Install Apache + PHP5: Still in your Putty Client window, type: yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php- xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel Then edit /etc/httpd/conf/httpd.conf: vi /etc/httpd/conf/httpd.conf find the DirectoryIndex line, and change it to: DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl After that, press Esc key on your keyboard, and type ":wq" (without quote) in your Putty. Now configure your system to start Apache at when rebooting: chkconfig --levels 235 httpd on 3 [Copyrights Reserved] Tony Wang http://www.shdol.com/ Start Apache: /etc/init.d/httpd start Up to this point, your web server is set up and ready to run PHP + MySQL applications. However, you need something like Webmin to facilitate your operation in future. Webmin Webmin is a web-based interface for system administration for Unix-like system (Linux). With Webmin, you can set up system user accounts, Apache web server, BIND DNS server, FTP Server, SSH server, etc. Webmin simplies system administration for Unix/Linux administrators, otherwise you would have to type command lines to configure Unix/Linux, which is obviously not user-friendly. You also can access your Linux server through SSH/Telnet. Putty, an open source SSH client, can be used to access your remote Linux server from your local computer. Putty can be downloaded here. Webmin was created by Jamie Cameron in 1997 and it has evolved significantly in the past 10 years. Many more modules for managing different servers and services have been added to Webmin. The user interface has 4 [Copyrights Reserved] Tony Wang http://www.shdol.com/ totally changed at least twice. And more operating systems are supported; the original was only for Solaris and Linux. If you ever used Cpanel/DirectAdmin control panel, you will find Webmin not so straightforward as its counterparts. However, Webmin is the lightest among these three applications. Webmin - Installation: Before you start installation, you want to surf this website http://www.webmin.com/download.html for the latest version. At the time of writing this article, the newest version of Webmin is 1.330 . Below is the procedures for downloading and installing Webmin: 1. Log in your remote VPS (or Dedicated server) through SSH as root. 2. Type in Putty: mkdir Webmin 3. Type: wget http://prdownloads.sourceforge.net/webadmin/webmin-1.330.tar.gz , which will take some time to finish. 4. Type: tar xvzf webmin-1.330.tar.gz 5.Type: cd webmin-1.330 6. Type: ./setup.sh /var/webmin Generally, you will be asked below questions and you can accept the default presented or change as you like: • Webmin configuration directory • The location at which Webmin will store logs • Path to Perl • Your server OS (Webmin does a good job of auto-detecting and will ask) • The port that Webmin will run on (defaults to 10000) • The user name and password to login to Webmin • Your server's hostname -- again, Webmin tries to detect this • Use SSL -- should only prompt if Perl's SSL libraries are installed (this author has not run Webmin under SSL) • Whether you want Webmin to start with system boot (highly recommended) As soon as Webmin is installed on your server box, you can access it by http://hostname.com:10000/ and enter your admin username and password that were just set. Once you are logged in, you will see the Webmin welcome scrreen and application control icons. You can try clicking every icon to see what they are. 5 [Copyrights Reserved] Tony Wang http://www.shdol.com/ If you did not install MySQL and/orApache web server, you can install them very easily by going to Webmin --> Servers. Click the MySQL database or Apache webserver icon, you will be prompted with a message like this: The *** server /path/to/the/server could not be found on your system. Maybe it is not installed, or your *** module configuration is incorrect. The*** package can be automatically installed by Webmin. Click here to have it downloaded and installed using YUM. (note: the *** can be any service name; in this case, it can be Apache or MySQL) All you need to do is click the link ' Click here ' to have the particular server installed by YUM.