Tips/Tutorials

Tech

XAMPP "Installation" without the Installer

Unzip the zip archives downloaded from the official XAMPP site into the folder of your choice. XAMPP is extracting to the subdirectory "xampp" below the selected target directory. Now start the file "setup_xampp.bat", to adjust the XAMPP configuration to your system (or to relocate the paths). You can set the necessary paths and variables for XAMPP with:

xamppxampp_shell.bat setenv

 

 


 

Edit file:

...xampp/apache/conf/httpd.conf

 

(...)

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>

ServerName myproject
DocumentRoot "C:/xampp/htdocs/myproject"
DirectoryIndex index.php
  <Directory "C:/xampp/htdocs/myproject ">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
ServerName phpmyadmin
DocumentRoot "C:/xampp/htdocs/phpmyadmin"
DirectoryIndex index.php
  <Directory "C:/xampp/htdocs/phpmyadmin">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
ServerName test
DocumentRoot "C:/xampp/htdocs/test"
DirectoryIndex index.php
  <Directory "C:/xampp/htdocs/test">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>



Edit File:

c:/WINDOWS/system32/drivers/etc/hosts

(...)

127.0.0.1                      localhost
127.0.0.1                      phpmyadmin
127.0.0.1                      myproject
127.0.0.1                      test

Virtual Hosts and the proper way to work offline

Hosts

Apache Virtual Hosts provide an easy way to host multiple offline versions of your client sites while still accessing them through a simple, canonical URL. It breaks down like this:

  • When you type a URL into your browser, the first thing it does is check a special file named HOSTS to see if it already knows where to direct the request
  • If the URL isn’t listed, it runs off to the internet to find out where to send you
  • BUT… if it is listed in the HOSTS file, the browser doesn’t bother finding out what to do from the internet; instead it goes straight to the IP address listed
  • If the listed location is 127.0.0.1, the request is not sent to the internet, but instead goes straight to your local machine’s Apache install

So far so good – we open up the HOSTS file (on Windows XP you’ll find it at C:/WINDOWS/system32/drivers/etc/, on earlier versions of Windows it’s at C:/WINDOWS/), and add a new line at the end for the offline version of our client site:

127.0.0.1   myclientsite.local

So now all requests for the URL myclientsite.local will be directed to my own Apache server – but how does Apache know what to do with them?

Virtual Hosts

Apache has a special section of its configuration file that tells it what to do with requests for different domains. You’ll find the file, named ‘httpd.conf’, in the /conf folder under your installation of Apache. Some versions might have removed the relevant section to a separate file named ‘httpd-vhosts.conf’ – mine is under /conf/extra, but if you can’t find yours, just do a search for “httpd”.

Once you’ve located the correct file, look for a section containing the text “NameVirtualHost 127.0.0.1”. You might need to uncomment this line (remove the #); below it you can then add entries for each site you want to serve from Apache, in this format:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1> ServerName localhost
DocumentRoot "C:Program Files\xampp\htdocs"
</VirtualHost>

This entry tells Apache that requests for “localhost” should be pointed to the folder listed under DocumentRoot (as you can tell, running XAMPP). For our client site, we simply add a new entry:

<VirtualHost 127.0.0.1>
    ServerName myclientsite.local
    DocumentRoot "C:Program Files\xampp\htdocs\myclientsite\version2"
    <Directory "C:Program Files\xampp\htdocs\myclientsite\version2">
         AllowOverride All
         Allow from all
    </Directory>
</VirtualHost>

And now all requests for http://myclientsite.local will be automagically routed to the specified folder, and your offline version of the client’s site can use all the features I mentioned above with no online/offline headaches (NB: if your Apache was running when you made the above change, you will have to stop and start it again before the change will take effect).

Note: the Directory tag might be necessary when the folder is not under the main localhost location.

To check virtual host configuration: from command prompt: /usr/local/apache/bin/httpd -S

Run IE6 and IE7, IE8 together

If you need to test something on IE6 and already have (as I hope) a newer version on your system, there is a convenient and easy solution to run IE6 without having to uninstall the current version. I found an interesting article with links and instructions that I am going to summarize for you.

First of all, download a copy of  Microsoft Windows Virtual PC 2007 and install it:

Basically now you have a local (multi) virtual machine console. You can use it to install different operating systems on different virtual PCs on your machine.

For our purpose, we need a Windows XP with IE6 pre-installed. It is provided by Microsoft as:
Internet Explorer Application Compatibility VPC Image.

The image file you need is XPSP3-IE6.EXE (Windows XP SP3 with IE6).

Install it and keep note of the chosen destination folder.

Now run Virtual PC 2007 and click on New to open the New Virtual Machine Wizard.

  1. Create a virtual machine
  2. Choose a name and a location (a name could be something like "WinXP-IE6") and click Next.
  3. Be sure that the operating system option in the drop-down list is Windows XP and click Next.
  4. Adjust the RAM to something more than 128MB (I would suggest 1020MB) and click Next.
  5. On the next window choose "A new virtual hard disk" and click Next.
  6. Choose a name and location (you might want to keep the one shown by default) and click Next.
  7. Click to Finish to complete the wizard.

 

Now select the virtual machine created and click on Settings.

Click on Hard Disk 1 and Browse to the destination folder created by the image installation above.

Then you should point to the image file IE6Compat.vhd

Confirm and close the settings panel.

--> Now your new virtual machine is ready. Click on Start to run it.

 

Please be sure to secure each virtual machine you create:

- Enable a firewall on each virtual machine;

- Install antivirus software on each virtual machine, as appropriate.