VPS Guide : Setup A New Website On Your VPS Server Easily

Posted on November 15th, 2012

Posted By Rishabh Jain | Comments

VPS Guide

Many of the users face this problem when they transfer their account from shared hosting to VPS server or purchase a new VPS. Well the main problem which occurs with everyone is they don’t know how to setup their website on the VPS server. So this article will explain a step by by step tutorial that how you can setup your websites on your VPS server without any problem.

 

There are some basic steps which you need to follow in order to setup your website.

By default your VPS comes with the default configuration of one website located in the following Directory:

 

/var/www/

 

HTML contents are located in the directory:

 

/var/www/html

 

CGI-BIN contents are located in:

 

/var/www/cgi-bin

 

To create an additional website, you need to create a location for the web contents and the entries within the httpd.conf file in order for the apache web server to locate the files to be served.

 

Follow the below simple steps to setup your website :-

  1. Create the new website directories.(We are using www2 as main directory or the new website)
  2. Setup the correct website permissions
  3. Create the entry in the apache configuration
  4. Test the setup
 

To create a new website,Follow the below steps :-

1. First connect to your VPS server SSH using Putty.

 

2.Change to the /var directory by typing the following:

 

cd /var

 

3.Create a new www directory in /var by typing the following:

 

mkdir www2

 

4.Change to the www2 directory by typing the following:

 

cd www2

 

5.Create the following directories using mkdir directoryname:

 

  • html: stores your html files
  • cgi-bin: stores your .cgi and .pl files
  • logs: stores your websites log files

 

6.Create the two log files used by the system by typing the following:

 

touch /var/www2/logs/www2_error_log

touch /var/www2/logs/www2_access_log

 

Now Follow below steps to setup the website permissions :-

 

Change to the /var directory by typing the following:

 

cd /var

 

Change the permissions on the directory by typing the following:

 

chmod -R 755 www2

 

Now follow these steps to create the entry in the apache configuration file :-

1.Open the httpd.conf file in VI by typing the following:

 

 vi /etc/httpd/conf/httpd.conf

 

2.Create a new VirtualHost container for your website. Each website must have its own container within the httpd.conf file. The container will look similar to the following:

 

<VirtualHost 0.0.0.0>
  ServerAdmin webmaster@domainname.com
  DocumentRoot /var/www2/html/
  ServerName www.domainname.com
  ServerAlias domainname.com
  ErrorLog /var/www2/logs/www2_error_log
  CustomLog /var/www2/logs/www2_access_log common

<Directory /var/www2/cgi-bin/>
  Options +ExecCGI
  AddHandler cgi-script cgi pl
</Directory>

</VirtualHost>

 

  • ServerAdmin: the email address of the website admin
  • DocumentRoot: the path to the server content or HTML files
  • ServerName: the default server address to be used for the site
  • ServerAlias: any other URLS that will be going to the site
  • ErrorLog: the path to the error log file
  • CustomLog: the path to the access log file
  • Directory container: allows you to setup special settings for a particular directory (for this example, we are setting up the cgi-bin dorectory to allow cgi and pl files to be executed)
 

Now all done. Its time to test the website you just created, Follow the below steps to test your website :-

 

1.Test your apache configure file by typing the following:

 

/usr/sbin/apachectl configtest
 
 
Output Should Be :-
 
Syntax OK
 
2.Now Restart the web service by typing the following:
/usr/sbin/apachectl graceful
3.Change to the www2/html directory by typing the following:
cd /var/www2/html
4.Create a test file by typing the following:
vi index.html
5.Enter some text and save the file.
6.Open the index.html page within a web browser. You should see your site.
If you face any problem in any of the steps mentioned above,you may contact us or comment below. 



About Rishabh Jain - Hello, I am rishabh Jain CEO Of Eden Web inc.