Tuesday, December 28, 2004

WAMP

There are other tutorials on how to set up Apache, PHP and MySQL on a Windows machine, but for what it's worth, this is how I do it. It's important to note that this is used on a testing server in a trusted environment. I have not gotten involved in any security issues here as it's not necessary in my particular case.

For the record, this applies to the following versions:

  • Windows XP Professional

  • Apache 1.3.31

  • PHP 4.3.10

  • MySQL 4.1.7


Let's get started!

Setting up Hosts

If you plan to use Apache's virtual hosts feature AND your testing server is on a different computer than the one you use, then you'll need to do some sorting out first. Virtual hosts allow you to run more than one website on a single web server. What this means is that you can have individual sites set up for each client, and be able to reference files in that site from the site root (or /) instead of just creating subdirectories for a single site as I have seen done elsewhere. For example, you can call http://client1 and pull up their test site, and http://project3 and see a completely different site, that can possibly be saved in a completely separate location on your hard drive.

For this to work, the computer running as your webserver should have a fixed IP address. And therefore each one of the computers in your intranet should also have fixed IPs. In Windows XP, click Start -> right-click My Network Places -> left-click Properties. (If you can't see it in your Start menu you can also get there via the Control Panel.) Then right-click the network connection that corresponds with your network card and left-click Properties. Scroll down the list if necessary until you can see TCP/IP. Double-click that and you'll see something like this:
Changing your TCP/IP settings

In this example, my workstation is called 192.168.0.5 and the computer that actually connects to the internet is 192.168.0.1. (Actually that's the address of my modem/router, but that's another story!) Assign a number along these lines to each machine in your intranet and adjust these settings accordingly. You will probably also need to obtain the DNS server addresses from your ISP and enter them into the lower section.

On a standard Windows installation you will find a file called hosts (with no extension - ie it's not called hosts.txt or anything like that) in C:\Windows\system32\drivers\etc. Open it in Notepad (or any other text editor) and below it add the hostnames you want to use next to the IP address you've allocated for your testing server. If the IP address of your testing server is 192.168.0.200, you might add:
192.168.0.200     client1 project3

You can keep adding hostnames, separating them with a space. When you fill the line, start a new one with the same IP address, a tab, and keep going with more names. I'm not sure how many names you can legally put on a line, but I found it stopped working for me if I had too many, so if that happens to you reduce the number on each line.

You will need to copy this file into the directory mentioned above on each computer in your intranet.

Now we can move on to setting up Apache!


Apache

  1. Download the instalation file from www.apache.org and run it.

  2. When prompted, use your computer's name (intranet in my example) as the server name

  3. Choose the desination directory. I prefer to keep all these things together, so I used C:\webserver\apache

  4. After the installation has finished, fire up your browser and enter your computer's name or ip address. You should see something like this:

  5. Apache confirmation page

  6. Now comes the fun - editing the httpd.conf file!


    • Line 342 - change AllowOverride to All (for htaccess files to work)

    • Line 385 - add extra filenames for the default document:
      DirectoryIndex index.html index.php index.php4

    • If you're using Virtual Hosts, uncomment Line 972 - NameVirtualHost *:80

    • Add details for your own virtual hosts as below:


    Adding virtual hosts

  7. Don't forget to restart Apache after making changes to httpd.conf, which you can do via Start -> Apache -> Control -> Restart



PHP

  1. Download the zip version of PHP from www.php.net and extract to C:\webserver, then change full php directory from php-4.3.10-Win32 to just php.

  2. There's a note in the install instructions: "Note: In PHP 4, you should move all files located in the dll and sapi folders to the main folder (e.g. C:\php)." - so do that. In this case, move them to c:\webserver\php

  3. To add the php directory to the system's path, right-click My Computer, choose the Advanced tab, and then click Environment Variables (near bottom of box). Find Path in system Variables, click Edit, and add ;c:\webserver\php to the end of what's already there. Don't forget the initial semi-colon. Click OK, then OK again. See below:

  4. Adjusting the path variable

  5. Rename php.ini-recommended to php.ini (it's in the main php directory)

  6. Now to edit the php.ini file:


  1. Line 397 deals with Magic Quotes. Check what your remote host has them set to and make this the same.

  2. Line 443 - change to extension_dir = "C:\webserver\php\extensions"

  3. Line 565 - uncomment the extension to load GD2

  4. Line 611 - add your ISP's SMTP server address

  5. Line 829 - Change to session.save_path = "C:\webserver\php\temp" and make sure you add a temp folder to your php folder


  • Go back to Apache's httpd.conf, and add this before the Virtual Hosts stuff at the bottom of the file:

  • LoadModule php4_module "c:/webserver/php/php4apache.dll"
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    # specify the directory where php.ini is
    SetEnv PHPRC c:/webserver/php
    # AddModule mod_php4.c

  • Create a PHP page with phpinfo() in it and make sure it works!



  • MySQL

    1. Download the 'essentials' version from www.mysql.com

    2. Choose custom install and change the installation directory as below:

    3. Changing installation directory in MySQL

    4. Choose Standard Config when prompted

    5. Install as a service

    6. Add root password (and don't forget what it is!)

    7. When done, create new file in the root of C called my.cnf, and add:

    8. [mysqld]
      basedir = C:webservermysql
      datadir = C:webservermysqldata

    9. If you haven't already, now is a good time to download phpMyAdmin and install that in a new folder with it's own hostname. Adjust the setting in its config file and fire it up. With a bit of luck you'll see two databases and you can start creating your own!

    Friday, December 24, 2004

    Politically correct seasons greetings

    In this age of the global village and the associated political correctness, you need to be careful what you say to people at this time of year.

    So it is timely I stumbled upon this:
    Please accept with no obligation, implied or implicit, this wish for an environmentally conscious, socially responsible, low stress, non-addictive, gender neutral, celebration of the coming holiday, practiced within the most enjoyable traditions of the religious persuasion of your choice, or secular practices of your choice, with respect for the religious/secular persuasions and/or traditions of others, or their choice not to practice religious or secular traditions at all; and a fiscally successful, personally fulfilling, and medically uncomplicated recognition of the onset of the generally accepted calendar year 2005, but not without due respect for the calendars of choice of other cultures, and without regard to the race, creed, colour, age, physical ability, religious faith, choice of computer platform, political inclinations, favourite sports team or sexual preference of the wishees. By accepting this greeting, you are accepting these terms. This greeting is subject to clarification or withdrawal. It is freely transferable with no alteration to the original greeting. It implies no promise by the wisher to actually implement any of the wishes for himself or others, and is void where prohibited by law, and is revocable at the sole discretion of the wisher. This wish is warranted to perform as expected within the usual application of good tidings for a period of one year, or until the issuance of a subsequent holiday greeting, whichever comes first, and warranty is limited to replacement of this wish or issuance of a new wish at the sole discretion of the wisher.

    Courtesy of Steve Davis

    Thursday, December 23, 2004

    What are Aussies searching for?

    Google have released their Australian top searches for 2004. The news everyone was waiting for? Shannon Noll was searched for more than Guy Sebastian! (Yep... we all needed to know that!) Also worth a look are the global results.

    Worth noting:

    • Janet Jackson was more popular than John Kerry (Maybe that explains the result of the US election)

    • Searches for cricket made number 8 in the sports list

    • The top 4 global searches were all females (Britney, Paris, Christina Aguilera and Pamela Anderson)


    Enough useless trivia? Yep!

    Sundry Links

    Maps
    Drawing navigation maps using Illustrator (but this really applies to any vector-based drawing program.)
    CSS Troubleshooting
    Dave Shea's CSS Crib Sheet should get you out of trouble. Maybe!
    Favourite Javascripts
    A collection of Javascript snippets. Some useful, some not so. Also links to a multi-level suckerfish-style flyout. (What a mouthful!)
    Woody
    A free program for creating seamless wood-lloking textures and tiles.
    Zebra Tables
    Creating tables with different colour or style on alternating rows.
    CSS Sprites
    Using a single image for CSS hover effects instead of using the old javascript preloaders.
    PHP image/text replacement
    Using PHP's GD image library to dynamically replace text with an image on the fly.
    Flash image replacement
    Using Flash for your page titles. I must get around to trying this out one day...

    Tuesday, December 21, 2004

    Cross Column Pullouts

    The latest issue of A List Apart deals with having pullouts span multiple columns.

    For the uninitiated, a pullout is the name for the box above that says "Can this box span multiple comuns?". Floating it within a single column of text is pretty simple. Spanning more than one column is a bit trickier.

    It looks great on a printed page, but I'm not sure why you'd want to create a multi-column content layout for screen output anyway. Why force your readers to scroll up and down the page more than once? I think the practical applications of this one are fairly limited. Although, having said that - I'm sure it could form the basis for something more practical.

    Waterfall Web is Born!

    I know there are archives here and such - but today I finally got around to putting this site up!


    The archived posts prior to this one are actually copied over from my old Blogspot blog. I'll abandon that one now and put everything here instead.


    What will this blog cover? Will anyone ever read it? Does anyone actually care?


    Stay tuned...

    Website Project Management Part 1 : Introduction

    It's probably fair to say that most website projects are not managed, they just happen. Do up some designs, slice the graphics and code it up, drop some content in and viola! We have a website!

    This might be okay if you're working on one or two at a time, but when you get to half a dozen or more, you'll quickly find you need some project management skills.

    I'll be outlining here over the next few posts a method that works for me. I'm always fine tuning it, so it's by no means perfect, but if you currently have no management system in place at all this will hopefully set you heading in the right direction.

    I'll be referring to phpCollab (as that's what we use), so it might be a good time to download, install and configure it before we go much further. There's setup instructions on their website, so I won't repeat them here.

    There's your homework for now, next time we'll deal with basic project management principles.

    Monday, December 13, 2004

    Embrace the Web for what it is

    The article A Dao of Web Design is a bit old now, but it's well worth another look. I had a client today looking for pixel-perfect placement across multiple browsers & screen resolutions. That's not what the web is about. Hours can be wasted getting line endings to be in exactly the right spot - and then on someone else's computer it will probably be different anyway!

    Embrace the control that the web puts in the hand of the user & you'll sleep much better at night!

    Sunday, December 5, 2004

    Browser Wars - Reloaded

    If you're reading this then you're probably aware that Microsoft's stranglehold on the browser market is slipping. A survey from late November tells a dramatic story. Since May, it's total market share has fallen by 5%. That's pretty substantial in 6 months, especially considering that the fall has been taken up by Mozilla's Firefox, which people have to choose to download and install. It's not part of anyone's operating system.

    It reinforces the need for testing of your website in multiple browsers and operating systems before it goes live. Whilst it was always a fallacy to only worry about one browser, now it's becoming statistically significant again.

    There are a few issues with testing, though. The first one is installing multiple versions of Internet Explorer on the same version of Windows. Joe Maddalone managed to figure out how it's all done, and to simplify the setup process I've packaged up version 3, 4, 5 and 5.5 into a single, simple installation file.

    After that installing Firefox, Netscape, Opera and whatnot are easy. Of course, that doesn't solve problems with IE5 for Mac or Safari if you're a PC-only office (like here)! So maybe it's worth signing up with Browsercam and being done with it! ;)