Apache-creating a virtual host

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

Shakthi777Asked:
Who is Participating?
 
finartCommented:
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
 
OrcenCommented:
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
 
Shakthi777Author Commented:
tnx !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.