How do I setup a new website on my VPS server?
The following article explains how to create a new website on your VPS server. Website configuration on the Virtuozzo VPS platform is handled from the httpd.conf file in the /etc/httpd/conf/ directory. This file is the main apache configuration file for the apache webserver application.
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.
- Create the new website directories. In this example we will use www2 as the main directory for the new website.
- Setup the correct website permissions
- Create the entry in the apache configuration
- Test the setup
To create a new website, please follow these steps:
- Open a web browser and connect to your VPS Power Panel located at http://ip address:4643.
- Login as the Administrator using the information sent to you in your setup email.
- Click SSH Connection from the VPS Services menu.
- Enter the root login and password and click Login.
- Change to the /var directory by typing the following:
cd /var - Create a new www directory in /var by typing the following:
mkdir www2 - Change to the www2 directory by typing the following:
cd www2 - 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
- Create the two log files used by the system by typing the following:
touch /var/www2/logs/www2_error_logtouch /var/www2/logs/www2_access_log
To setup the website permissions, please follow these steps:
- 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
This will give the user full access to the directory while limiting everyone else to read and execute permissions.
To create the entry in the apache configuration file, please follow these steps:
- Open the httpd.conf file in VI by typing the following:
vi /etc/httpd/conf/httpd.conf - 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 65.36.160.111:80>
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)
Note: The Virtual host container can contain almost any apache directive. See http://httpd.apache.org/ for additional directives.
To test the site you just created, please follow these steps:
- Test your apache configure file by typing the following:
/usr/sbin/apachectl configtest
You should see the following response:
Syntax OK
Note: If it returns an error, please review the error message, make the necessary corrections and rerun the command. - Restart the web service by typing the following:
/usr/sbin/apachectl graceful - Change to the www2/html directory by typing the following:
cd /var/www2/html - Create a test file by typing the following:
vi index.html - Enter some text and save the file.
- Open the index.html page within a web browser. You should see your site.




