How to setup a website in CentOS VPS

Today i would be blogging something special for all newbies who have a vps (cheap or costly doesn’t matter) with CentOS Operating System Installed. So I would be writing how to setup one of my site, In this tutorial i would be setting up domain “” in my new CentOS VPS.

Please note, This is one of the simplest methods for CentOS and ofcourse there are other ways too!

Tools Required:

  1. Putty
  2. WinSCP (A very cool program for editing files, Uploading and downloading from the VPS)

So like the others, I have the CentOS VPS Putty details with me and i have successfully logged in to putty as “root” user.

login as: root’s password:
[root@s2 ~]#

By default, All VPS comes with Apache HTTP Server installed, so we will proceed with the installation of MySQL.

To Install MySQL, Enter this code :

yum install mysql mysql-server

Follow the instructions on the screen, At most cases you will be prompt to enter root password, If your not asked then the root password will be blank.

Now for making MySQL to startup automatically at boot time, Enter this command in SSH :

chkconfig –levels 235 mysqld on

Now Let’s start MySQL by entering this command :

/etc/init.d/mysqld start

Ok, So MySQL is started up, Now lets install PHP, Run the codes below :

yum install php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

After install PHP, Restart Apache HTTP Server by running this code :

/etc/init.d/httpd restart

For MySQL, you can run “mysql -p” command in SSH and manage your databases!

Now create a directory in /home For example “directoryofthewebsitecontent” and upload files to it.

Now Open WinSCP, Login and navigate to /etc/httpd/conf

Paste this code at the last line :

<VirtualHost IPOFTHESERVER:80>
ServerAdmin<br /> DocumentRoot /home/directoryofthewebsitecontent
ErrorLog logs/
CustomLog logs/ common

Replace with your domain & directoryofthewebsitecontent with the directory you have created.

That’s All. Your comments are welcome 🙂

January 28, 2012
Previous Post Next Post

Tharun recommends you to read these fantastic articles