Answer the question
In order to leave comments, you need to log in
How to run 2 sites locally?
I have site1.conf
running
<VirtualHost 127.0.0.1:80>
ServerName dt.dev
ServerAlias www.dt.dev
.....
<VirtualHost 127.0.0.1:8888>
ServerName www.ez.dev
ServerAlias ez.dev
Answer the question
In order to leave comments, you need to log in
<VirtualHost 127.0.0.1:80>
ServerName www.ez.dev
ServerAlias ez.dev
Virtualhost does not work by ports, but by dns name.
The port (or ports) to listen on is defined globally.
When you enter the site, the web server looks at which domain name you got to it, and depending on the availability of the necessary virtualhosts with the specified names, it throws you into the desired documentroot. If a suitable virtualhost is not found, it throws on the one that you have specified by default (the first one).
So it's right to do
<VirtualHost dt.dev>
ServerName dt.dev
ServerAlias www.dt.dev
<VirtualHost ez.dev>
ServerName www.ez.dev
ServerAlias ez.dev
127.0.0.1 ez.dev
127.0.0.1 www.ez.dev
127.0.0.1 dt.dev
127.0.0.1 www.dt.dev
Did you specify port 8888 in ez.dev?
In general, put port 80 in both cases.
site1.conf
DocumentRoot "/var/www/site1"
ServerName site1.local
ServerAlias site1.local
AllowOverride All
RewriteEngine On
Options Indexes FollowSymlinks
ErrorLog /var/www/site1-error.log
LogLevel warn
site2.conf
DocumentRoot "/var/www/ site2"
ServerName site2.local
ServerAlias site2.local
AllowOverride All
RewriteEngine On
Options Indexes FollowSymlinks
ErrorLog /var/www/site2-error.log
LogLevel warn
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question