Solved

Apache-creating a virtual host

Posted on 2010-08-31
3
482 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
Comment Utility
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
Comment Utility
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
Comment Utility
tnx !
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now