Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I think this is a simple question, but let me explain better. I have the following development environment:

  • Ubuntu Server 12.04 LTS;
  • Apache 2.4;
  • PHP 5.5;

Everything is working fine, except the VirtualHost configuration. I want to deploy two applications: Drupal and Wordpress. Each application has your own directory, for example:

  • Drupal: /l/disk0/drupal/public_html;
  • Wordpress: /l/disk0/wordpress/public_html;

In default site, VirtualHost configuration points to /var/www as document root. I want to disable this default-site configuration and I want to create two VirtualHosts, one for Drupal and another one for Wordpress.

However, this is a development environment and there is no domain here. I've searched many sites and I found a lot of tutorials, all of them explains how to do this with domains, but not with subdirectories.

After doing the configuration, the URL to access my applications will be:

 - http://example.com/wordpress;
 - http://example.com/drupal;

I already try with this VirtualHost:

<VirtualHost *:80>
        ServerName example.com
        ServerAdmin web@myserver.com
        DocumentRoot /l/disk0/site/public_html

        <Directory />
                AllowOverride None
        </Directory>

        Alias /site /l/disk0/site/public_html
        <Directory /l/disk0/site/public_html>
                Options MultiViews Indexes Includes FollowSymLinks ExecCGI
                AllowOverride All
                Require all granted
                allow from all
        </Directory>

        RewriteEngine On
        LogLevel warn
        ErrorLog "/l/disk0/site/logs/apache/site/error.log"
        CustomLog "/l/disk0/site/logs/apache/site/access.log" combined
        SSLProxyEngine on
</VirtualHost>

Didn't work.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

VirtualHost is used when you want to have a separate domain name for each site. When apache chooses which virtualhost to use, it looks at the domain name part of the URL. So when that part is the same, it means you cannot split it up using VirtualHosts.

You have two choices:

  • Use separate hostnames, e.g. drupal.example.com and wordpress.example.com instead of example.com/drupal and example.com/wordpress

  • Use another way to separate the two sites.

In the former case, you would keep your VirtualHost configs but you would change the ServerName in each.

In the latter case, you would remove the VirtualHost configuration and instead do something like

    Alias /drupal /l/disk0/drupal/public_html
    <Directory /l/disk0/drupal/public_html>
            Options MultiViews Indexes Includes FollowSymLinks ExecCGI
            AllowOverride All
            Require all granted
            allow from all
    </Directory>

    Alias /wordpress /l/disk0/wordpress/public_html
    <Directory /l/disk0/wordpress/public_html>
            Options MultiViews Indexes Includes FollowSymLinks ExecCGI
            AllowOverride All
            Require all granted
            allow from all
    </Directory>
share|improve this answer
    
Thanks. It makes sense now. I created one VirtualHost and inside this VirtualHost I've added the directories and the alias like you said. It's working fine now. –  Ricardo Giaviti Mar 17 at 17:13
    
Glad it worked! –  Jenny D Mar 17 at 19:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.