Solved

Apache-creating a virtual host

Posted on 2010-08-31
3
493 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux/Apache File Ownership/Permissions 1 63
is my large folder zipped corrupted 4 65
PHP: Insert Data into MySQL 5 39
how to configure linux OS using Ubuntu 7 39
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

776 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