Solved

Apache-creating a virtual host

Posted on 2010-08-31
3
499 Views
Last Modified: 2012-05-10
Hi Experts,

Below is my currently running httpd.conf which I don't understand.

I just need to create another virtual host locating to another folder in the web root.

Please advise and thanks !
## 
##


Listen xx.yy.xxx.yyy:80
Listen xx.yy.xxx.yyy:443

ServerRoot /www
DocumentRoot /web/root
PidFile /var/run/httpd.pid

Timeout 300
ServerSignature on
ServerAdmin postmaster@mywebserver.com
ServerName dev.mywebserver.com
UseCanonicalName off
ServerTokens OS

User apache
Group apache

# Assume no memory leaks at all
MaxRequestsPerChild 0

# Server tuning
Include /www/conf/server-tuning.conf

# Default Error Log
ErrorLog /var/log/apache/error_log
LogLevel debug

# Load Modules
Include /www/conf/modules.conf

# Module config files
Include /www/conf/mod_log.conf
#Include /www/conf/mod_security-defaults-1.conf
Include /www/conf/mod_mime-defaults.conf
Include /www/conf/mod_autoindex-defaults.conf
Include /www/conf/passenger.conf
TypesConfig /www/conf/mime.types
DefaultType text/plain
Include /www/conf/mod_mime-defaults.conf
Include /www/conf/errors.conf
Include /www/conf/php.conf
#Include /www/conf/python.conf
Include /www/conf/dav_svn.conf

# RewriteOptions
#MaxRedirects=20
#LimitInternalRecursion 20

# Log type and path
CustomLog /var/log/apache/access_log combined

# Index page types
DirectoryIndex index.php index.html

# common server settings
Include /www/conf/default-server.conf

# SSL server settings
<IfModule mod_ssl.c>
    Include conf/ssl.conf
</IfModule>

## USE DYNAMIC PATHS
# Server Documents Directory
#<Directory "/web/root">
#    Options +ExecCGI +FollowSymLinks +MultiViews +Indexes
#    AllowOverride All
#    Order allow,deny
#    Allow from all
#    # Per-directory URL ReWriting Module Rules
#    RewriteEngine On
#    RewriteBase /
#    #RewriteRule to remove VirtualDocumentRoot and Session ID from URL
#    #in the form of tld/domain/host/session_id/requested_page
#    RewriteRule ^[a-z\.]{1,10}/[a-z0-9_-]{1,64}/[a-z0-9]{1,20}/[0-9a-z]{32}/(.+) /$1
#</Directory>
#
#VirtualDocumentRoot /web/root/%3+/%2/%1
#VirtualScriptAlias /web/root/%3+/%2/%1/cgi-bin


## USE FIXED PATHS
# Server Documents Directory
<Directory "/web/root">
    Options +ExecCGI +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<Directory "/web/root/com/app1/phpdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<Directory "/web/root/com/app1/trac">
    Options Indexes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>


## Virtual Hosts


NameVirtualHost xx.yy.xxx.yyy:80

# Application development web root
<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mywebserver.com
        DocumentRoot /web/root/com/app1/dev
        ServerName dev.mywebserver.com
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
</VirtualHost>

<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin app_dep@App1
        ServerName deploy.mywebserver.com
        DocumentRoot /web/root/app1/webistrano/public
        RailsEnv production
</VirtualHost>


# Application development documentation
<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mywebserver.com
        DocumentRoot /web/root/com/app1/phpdocs
        ServerName phpdocs.mywebserver.com
        Options Indexes FollowSymLinks
</VirtualHost>


<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mydomain2.com
        DocumentRoot /web/root/com/app1/app3
        ServerName dev.mywebserver.com
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
</VirtualHost>

<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mydomain2.com
        DocumentRoot /web/root/com/app1/legacy_apps/ajentia/Application
        ServerName legacy.mywebserver.com
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
</VirtualHost>


<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mydomain2.com
        DocumentRoot /web/root/com/app1/trac
        ServerName trac.mywebserver.com
        <Location /login>
                AuthType Basic
                AuthName "trac"
                AuthUserFile /web/root/com/app1/trac/.htpasswd
                Require valid-user
        </Location>
        <Location />
                AuthType Basic
                AuthName "trac"
                AuthUserFile /web/root/com/app1/trac/.htpasswd
                Require valid-user
                SetHandler mod_python
                PythonInterpreter main_interpreter
                PythonHandler trac.web.modpython_frontend
                PythonOption TracEnv  /web/root/com/app1/trac
                PythonOption TracUriRoot /
                PythonDebug On
        </Location>
</VirtualHost>

# Application Flex development web root
<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mywebserver.com
        DocumentRoot /web/root/com/app1/flexdev
        ServerName flexdev.mywebserver.com
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
</VirtualHost>

# pgrav Flex development web root
<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mywebserver.com
        DocumentRoot /web/root/com/app1/pgdev
        ServerName pgdev.mywebserver.com
        DirectoryIndex index.html
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
</VirtualHost>

Open in new window

0
Comment
Question by:Shakthi777
3 Comments
 
LVL 2

Assisted Solution

by:Orcen
Orcen earned 100 total points
ID: 33573181
Hello, you can add something like this under ## Virtual Hosts


NameVirtualHost YOURSERVERIP:80
<VirtualHost YOURSERVERIP:80>
        DocumentRoot /home/YOURACCOUNT/public_html
        ServerName DOMAIN.COM
        ServerAlias www.DOMAIN.COM
</VirtualHost>
0
 
LVL 1

Accepted Solution

by:
finart earned 400 total points
ID: 33574368
Hello,
Please state what distribution you are using and if SELinux is enabled.
Effectively, if SELinux is enabled, you should verify that apache is authorized to read files in your web directory.
Ok, now, assuming that SELinux is either not enabled, or rightly configured, you have to:
1) create the directory for your website:
    mkdir /web/root/mynewwebsite
2) populate the directory with your website content
3) change the owner of files to be sure that apache has the right to read those files
    chown -R apache:apache /web/root/mynewwebsite
4) add the following lines to your httpd.conf
<VirtualHost xx.yy.xxx.yyy:80>
        ServerAdmin webmaster@mywebserver.com
        DocumentRoot /web/root/mynewwebsite
        ServerName mynewwebsite.mywebserver.com
        DirectoryIndex index.html
        Options Indexes ExecCGI FollowSymLinks
        RewriteEngine On
</VirtualHost>
5) verify that the config file is ok
    apachectl configtest
 or depending from your distro
   apache2ctl configtest
6) if previous test was ok, you have to reload the config
    apachectl graceful
  or depending from your distro
    apache2ctl graceful

Regards

Pascal
0
 

Author Closing Comment

by:Shakthi777
ID: 33579515
tnx !
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question