Ok, so you have a new VPS. Now what do you do with it?

For many users, a box with a Lamp setup, Linux Apache Mysql and Perl/Php/Python is a good point to start building their server.


Setting up a Lamp box is really quite simple, thanks to the popular Yum package manager that comes with Redhat based distros like Centos or Fedora.

In this howto, we will create a Centos 4.3 based box with Apache/Mysql/Php,
as well as Webmail, and Vsftp.

Lets start with the first step.

* Install a new stock Centos distro via your hosting providers control panel.
* After your distro installs and the system boots up, login via ssh.
* Type the following:

yum install httpd mysql mysql-server php php-mysql sendmail dovecot squirrelmail vsftpd

* A large amount of text will scroll by as Yum resolves its dependancies for the above software. Answer Y to the following question.

Transaction Summary
Install 18 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 22 M
Is this ok [y/N]:

* Yum will download the packages, and install them happily as you instructed it to do so.
* When its done, you will be returned to the command prompt. Your software has been installed, lets make sure its running. Type the following to start your daemons up.

service httpd start
service vsftpd start
service mysqld start...

Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]

* Oops!!! What happened with Mysql? Rpm based distros have an unfortunate bug associated with them. A few steps will be needed before mysql will start correctly. You will need to edit /etc/my.cnf

It looks like this:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Make it look like this:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
skip-innodb
skip-bdb

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Then, type:

service mysqld start
Starting MySQL: [ OK ]

* There we go. Now, we need to make a few changes to dovecot to make it run both imap and pop3.

edit /etc/dovecot.conf

Turn this:

# Protocols we want to be serving:
# imap imaps pop3 pop3s
#protocols = imap imaps

into this:

# Protocols we want to be serving:
# imap imaps pop3 pop3s
protocols = imap imaps pop3

Then start dovecot up.

service dovecot start
Starting Dovecot Imap: [ OK ]

* Thats it, you have installed an Linux/Apache/Mysql/Php server, with webmail too boot!

* Oh, where is the webmail on the system?

Just put your vps's IP in a browser like this:

http://my.ip.add.ress/webmail/

* Lets make sure these daemons start up when then vm boots:

chkconfig --levels 3 httpd on
chkconfig --levels 3 mysqld on
chkconfig --levels 3 vsftpd on
chkconfig --levels 3 dovecot on


Thats it! You now have a basic LAMP server up and running.
This could be improved apon by installing an open source control panel like Webmin.