Solved

Apache-creating a virtual host

Posted on 2010-08-31
3
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…
Suggested Courses

622 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