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 [email protected]
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.
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
andwordpress.example.com
instead ofexample.com/drupal
andexample.com/wordpress
Use another way to separate the two sites.
In the former case, you would keep your
VirtualHost
configs but you would change theServerName
in each.In the latter case, you would remove the
VirtualHost
configuration and instead do something like