Posted by:
RiggsFolly
(---.dynamic.dsl.as9105.com)
Hi Malcolm,
The folder 'project1' is just a folder name into which you place your website code, it has no relation to the actual domain name until Apache sees your Virtual Hosts definition.
The part that associates the folder name 'project1' with an actual domain name is the 'DocumentRoot' and 'ServerName' directives that you use in the Virtual Host definition.
So if you place your website pages/code into '\wamp\www\project1' then the Virtual Hosts Definition
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/project1" <-- this is the folder that holds
ServerName project1.dev <-- this domain
ServerAlias www.project1.dev <-- and this alias for that domain
<Directory "c:/wamp/www/project1"> <-- this section defines access rights to the domain
AllowOverride All
Require local
</Directory>
</VirtualHost>
Also the folder you place the website code into does not have to exist below the '\wamp\www' folder. You could do something like this to move the website code from the wamp folder completely
So you could create
'c:\websites\project1\www' and 'c:\websites\project2\www'
folders to hold 2 seperate sites. Then define the 2 Virtual Hosts so Apache knows where to get those sites from like so
<VirtualHost *:80>
DocumentRoot "c:\websites\project1\www"
ServerName project1.dev
ServerAlias www.project1.dev
<Directory "c:\websites\project1\www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:\websites\project2\www"
ServerName project2.com
ServerAlias www.project1.com
<Directory "c:\websites\project2\www">
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
This also helps you have more than one project under development or maintenance at the same time. You can also control their access privilages seperately by amending 1 site to allow access from places other than the local machine eg the 'Requie' directive. See project2's VHost definition.
There are also other advantages in using VHOST's, for example if you have one site that requires some amendments to the PHP parameters required to run the site. For example if project2 requires additional PHP limits to run you can amend those just for that specific site like so :-
<VirtualHost *:80>
DocumentRoot "c:\websites\project2\www"
ServerName project2.com
ServerAlias www.project1.com
<Directory "c:\websites\project2\www">
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
</VirtualHost>
[/code]
This serves to allow you to make the amendment, but for them to be specific to just that site. This is also self documenting, so when you come to move the site to a live hosted environment you should be able to see what changes you had to make to get this site running as you want it.
I hope this clears up any lack of clarity in my original document.
---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>Read The Manuals Apache --
MySQL --
PHP --
phpMyAdminGet your Apache/MySQL/mariaDB/PHP ADDONs here from the
WAMPServer alternate Repo-X-X-X-
Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-
Edited 3 time(s). Last edit at 09/25/2014 10:30AM by RiggsFolly.