Different code bases php
Posted by: FreddyNoNose (---.socal.res.rr.com)
Date: October 13, 2014 03:00AM

WAMP Version 2.2
Apache Version : 2.2.21
PHP Version : 5.3.10
Firefox: 32.0.3
Green Wamp Icon

From a development point of view, it is nice to have different areas (projects/sandboxes/codebase) for different versions of the project. Not just alpha/beta/release, but Developer bob, joe and sally each get their own area to work with so they can push changes to test without affecting the other team members. Is there an easy way to create such spaces in WAMP. By WAMP, I mean WAMP running on a single system. I want to avoid the answer that is just give each person their own X rather than use a single system.

Options: ReplyQuote
Re: Different code bases php
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: October 13, 2014 09:57AM

Well of course the correct answer is 'the answer you dont want' i.e. give bob, sally, and joe WAMPServer on their PC's. Afterall that is what WAMPServer was designed to be for.

However, if you were to create a Virtual Host on the server for your projects UAT environment, and then one for each developers DEV environmant something like

project.uat

project.bob
project.dev
project.dev

That would work when kept on a single server.

Then just change the HOSTS file one each individual machine to match their dev domain So if WampServer was running on 192.168.1.10

On bob
192.168.1.10 project.bob
192.168.1.10 project.uat

On joe
192.168.1.10 project.joe
192.168.1.10 project.uat

etc.

This will help you How to setup Virtual Hosts

Of course now you would just be in SOURCE_HELL unless you have a decent source managment tool!!!!!!

---------------------------------------------------------------------------------------------
(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 -- phpMyAdmin
Get 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-

Options: ReplyQuote
Re: Different code bases php
Posted by: Emmy wilson (197.157.17.---)
Date: October 13, 2014 12:11PM

Actually this should work basically the same for any windows Apache server, with differences only in where you may find the Apache config files.

There are 3 steps to create your first Virtual Host in Apache, and only 2 if you already have one defined.

1. Create the Virtual Host definition(s)
2. Add your new domain name to the HOSTS file.
3. Uncomment the line in httpd.conf that includes the Virtual Hosts definition file.

Step 1, Create the Virtual Host definition(s)

Edit the file called `httpd-vhosts.conf` which for WampServer lives in

\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf

(Apache version numbers may differ, engage brain before continuing)

-- If this is the first time you edit this file, remove the default example code, it is of no use.

I am assuming we want to create a definition for a site called project1 that lives in

\wamp\www\project1

Very important, first we must make sure that localhost still works so that is the first VHOST definition we will put in this file.

<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>

Now we define our project: and this of course you do for each of your projects as you start a new one.

<VirtualHost *:80>
DocumentRoot "c:/wamp/www/project1"
ServerName project1
<Directory "c:/wamp/www/project1">
AllowOverride All
Require local
</Directory>
</VirtualHost>


Note: each VHOST definition has its own DocumentRoot definition.

Small aside
The way virtual hosts work in Apache: The first definition in this file will also be the default site, so should the domain name used in the browser not match any actually defined virtually hosted domain, making localhost the first domain in the file will therefore make it the site that is loaded if a hack attempt just uses your IP Address.
So if we ensure that the Apache security for this domain **is ALWAYS SET TO**

Require local

any casual hack from an external address will receive an error and not get into your PC, but should you misspell a domain you will be shown the WampServer homepage, because you are on the same PC as WampServer and therfore `local`.



Setp 2:

Add your new domain name to the HOSTS file.
Now we need to add the domain name that we have used in the Virtual Host definition to the HOSTS file so that windows knows where to find it. This is similiar to creating a DNS A record, but it is only visible in this case on this specific PC.

Edit `C:\windows\system32\drivers\etc\hosts`

The file has no extension and should remain that way. Watch out for notepad, as it may try and add a `.txt` extension if you have no better editor.
I suggest you download Notepad++, its free and a very good editor.

Also this is a protected file so you must edit it with administrator privileges, so launch you editor using the Run as Administrator menu option


The hosts file should look like this when you have completed these edits

127.0.0.1 localhost
127.0.0.1 project1

::1 localhost
::1 project1

Note that you should have definitions in here for the IPV4 loopback address `127.0.0.1` and also the IPV6 loopback address `::1` as Apache is now IPV6 aware and the browser will use either IPV4 or IPV6 or both. I have no idea how it decides which to use, but it can use either if you have the IPV6 stack turned on, and most window OS's do as of XP SP3.


Now we must tell windows to refresh its domain name cache, so launch a command window again using the Run as Administrator menu option again, and do the following.

net stop dnscache
net start dnscache

This forces windows to clear its domain name cache and reload it, in reloading it will re-read the HOSTS file so now it knows about the domain `project1`.

Step 3: Uncomment the line in httpd.conf that includes the Virtual Hosts definition file.

Edit your httpd.conf, use the wampmanager.exe menus to make sure you edit the correct file.

Find this line in httpd.conf

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

And just remove the `#` to uncomment the Include line.

To activate this change in you running Apache we must now stop and restart the Apache service.

wampmanager.exe -> Apache -> Service -> Restart Service


Now if the WAMP icon in the system tray does not go GREEN again, it means you have probably done something wrong in the `\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf` file.

If so here is a useful mechanism to find out what is wrong. It uses a feature of the Apache exe (httpd.exe) to check its config files and report errors by filename and line numbers.


Launch a command window.

cd \wamp\bin\apache\apache2.4.9\bin
httpd -t


So fix the errors and retest again until you get the output

Syntax OK

Options: ReplyQuote
Re: Different code bases php
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: October 13, 2014 12:25PM

Thanks for helping out Emmy.

---------------------------------------------------------------------------------------------
(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 -- phpMyAdmin
Get 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-

Options: ReplyQuote
Re: Different code bases php
Posted by: FreddyNoNose (---.socal.res.rr.com)
Date: October 13, 2014 09:23PM

RiggsFolly Wrote:
-------------------------------------------------------
> Well of course the correct answer is 'the answer
> you dont want' i.e. give bob, sally, and joe
> WAMPServer on their PC's. Afterall that is what
> WAMPServer was designed to be for.
>
> However, if you were to create a Virtual Host on
> the server for your projects UAT environment, and
> then one for each developers DEV environmant
> something like
>
> project.uat
>
> project.bob
> project.dev
> project.dev
>
> That would work when kept on a single server.
>
> Then just change the HOSTS file one each
> individual machine to match their dev domain So if
> WampServer was running on 192.168.1.10
>
> On bob
> 192.168.1.10 project.bob
> 192.168.1.10 project.uat
>
> On joe
> 192.168.1.10 project.joe
> 192.168.1.10 project.uat
>
> etc.
>
> This will help you
> [url=http://forum.wampserver.com/read.php?2,127757
> ]How to setup Virtual Hosts[/url]
>
> Of course now you would just be in SOURCE_HELL
> unless you have a decent source managment
> tool!!!!!!

Thank you for the answer. What you call the "correct answer" is actually off topic to the question if you want to "be technical", which I why I qualified the scenario. Although off topic, I would have accepted the answer of you giving me a few million dollars in cash as a gift! grinning smiley

FYI, there is no bob/sally. This is just me at home not wanting to spend money and doing it on the cheap. If I wanted to spend money, I would be doing that.

In any case, what prompted me to look at the subject was the great book, Refactoring Databases.

Options: ReplyQuote
Re: Different code bases php
Posted by: FreddyNoNose (---.socal.res.rr.com)
Date: October 13, 2014 09:24PM

Emmy wilson Wrote:
-------------------------------------------------------
> Actually this should work basically the same for
> any windows Apache server, with differences only
> in where you may find the Apache config files.
>
> There are 3 steps to create your first Virtual
> Host in Apache, and only 2 if you already have one
> defined.
>
> 1. Create the Virtual Host definition(s)
> 2. Add your new domain name to the HOSTS file.
> 3. Uncomment the line in httpd.conf that includes
> the Virtual Hosts definition file.
>
> Step 1, Create the Virtual Host definition(s)
>
> Edit the file called `httpd-vhosts.conf` which for
> WampServer lives in
>
> \wamp\bin\apache\apache2.4.9\conf\extra\httpd-vho
> sts.conf
>
> (Apache version numbers may differ, engage brain
> before continuing)
>
> -- If this is the first time you edit this file,
> remove the default example code, it is of no use.
>
> I am assuming we want to create a definition for a
> site called project1 that lives in
>
> \wamp\www\project1
>
> Very important, first we must make sure that
> localhost still works so that is the first VHOST
> definition we will put in this file.
>
> <VirtualHost *:80>
> DocumentRoot "c:/wamp/www"
> ServerName localhost
> ServerAlias localhost
> <Directory "c:/wamp/www">
> AllowOverride All
> Require local
> </Directory>
> </VirtualHost>
>
> Now we define our project: and this of course you
> do for each of your projects as you start a new
> one.
>
> <VirtualHost *:80>
> DocumentRoot "c:/wamp/www/project1"
> ServerName project1
> <Directory "c:/wamp/www/project1">
> AllowOverride All
> Require local
> </Directory>
> </VirtualHost>
>
>
> Note: each VHOST definition has its own
> DocumentRoot definition.
>
> Small aside
> The way virtual hosts work in Apache: The first
> definition in this file will also be the default
> site, so should the domain name used in the
> browser not match any actually defined virtually
> hosted domain, making localhost the first domain
> in the file will therefore make it the site that
> is loaded if a hack attempt just uses your IP
> Address.
> So if we ensure that the Apache security for this
> domain **is ALWAYS SET TO**
>
> Require local
>
> any casual hack from an external address will
> receive an error and not get into your PC, but
> should you misspell a domain you will be shown the
> WampServer homepage, because you are on the same
> PC as WampServer and therfore `local`.
>
>
>
> Setp 2:
>
> Add your new domain name to the HOSTS file.
> Now we need to add the domain name that we have
> used in the Virtual Host definition to the HOSTS
> file so that windows knows where to find it. This
> is similiar to creating a DNS A record, but it is
> only visible in this case on this specific PC.
>
> Edit `C:\windows\system32\drivers\etc\hosts`
>
> The file has no extension and should remain that
> way. Watch out for notepad, as it may try and add
> a `.txt` extension if you have no better editor.
> I suggest you download Notepad++, its free and a
> very good editor.
>
> Also this is a protected file so you must edit it
> with administrator privileges, so launch you
> editor using the Run as Administrator menu option
>
>
> The hosts file should look like this when you have
> completed these edits
>
> 127.0.0.1 localhost
> 127.0.0.1 project1
>
> ::1 localhost
> ::1 project1
>
> Note that you should have definitions in here for
> the IPV4 loopback address `127.0.0.1` and also the
> IPV6 loopback address `::1` as Apache is now IPV6
> aware and the browser will use either IPV4 or IPV6
> or both. I have no idea how it decides which to
> use, but it can use either if you have the IPV6
> stack turned on, and most window OS's do as of XP
> SP3.
>
>
> Now we must tell windows to refresh its domain
> name cache, so launch a command window again using
> the Run as Administrator menu option again, and do
> the following.
>
> net stop dnscache
> net start dnscache
>
> This forces windows to clear its domain name cache
> and reload it, in reloading it will re-read the
> HOSTS file so now it knows about the domain
> `project1`.
>
> Step 3: Uncomment the line in httpd.conf that
> includes the Virtual Hosts definition file.
>
> Edit your httpd.conf, use the wampmanager.exe
> menus to make sure you edit the correct file.
>
> Find this line in httpd.conf
>
> # Virtual hosts
> #Include conf/extra/httpd-vhosts.conf
>
> And just remove the `#` to uncomment the Include
> line.
>
> To activate this change in you running Apache we
> must now stop and restart the Apache service.
>
> wampmanager.exe -> Apache -> Service -> Restart
> Service
>
>
> Now if the WAMP icon in the system tray does not
> go GREEN again, it means you have probably done
> something wrong in the
> `\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vho
> sts.conf` file.
>
> If so here is a useful mechanism to find out what
> is wrong. It uses a feature of the Apache exe
> (httpd.exe) to check its config files and report
> errors by filename and line numbers.
>
>
> Launch a command window.
>
> cd \wamp\bin\apache\apache2.4.9\bin
> httpd -t
>
>
> So fix the errors and retest again until you get
> the output
>
> Syntax OK

Thank you Emmy!

Options: ReplyQuote
Re: Different code bases php
Posted by: RiggsFolly (---.dynamic.dsl.as9105.com)
Date: October 14, 2014 12:08AM

Freddy,

Hey thanks fo beating me up for answering the question you asked rather than the one you wanted the answer to.

If you want to be technical..... Emmy answer was just a plagarism of my post which I pointed you too.

If you want to be able to do what you are suggesting then get GIT ( It's free, so its within budget ), learn to use it.

---------------------------------------------------------------------------------------------
(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 -- phpMyAdmin
Get 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-

Options: ReplyQuote


Sorry, only registered users may post in this forum.