Tuesday, February 15, 2005

Setting up a WAMP Server

Originally from http://www.sitewip.com/wamp/

Overview
This document is intended to walk you through the steps to create a full development server on your win32 system. I have tried to include all the steps I used to create a system that will allow you to develop on your local machine and match 95% of actual environment you will experience on a live *nix server.

I have completed this on Windows 95, Windows 98, Windows 2000 Professional +, and Windows XP (both home and professional). Windows 95 & 98 will require you to start the services listed below manually as they do not have a "Services" system like the others.

Required Downloads
The following is a list of the requirements for installing your system. 98% of all software we will discuss will be Open Source (free). Please support Open SourceYou should download these files and store them on your system in a place easy to find later. Once you have all these programs you are ready for the next step. This document will assume you have a c:\disks\ directory and create a new directory for each download ex: c:\disks\mysql\, c:\disks\php\, etc..

MySQL
Site: http://www.mysql.com/
Documentation: http://www.mysql.com/doc/en/index.html
Download: http://www.mysql.com/downloads/index.html (Production release)
The MySQL database server is the world's most popular open source database. Its architecture makes it extremely fast and easy to customize. Extensive reuse of code within the software and a minimalistic approach to producing functionally-rich features has resulted in a database management system unmatched in speed, compactness, stability and ease of deployment. The unique separation of the core server from the table handler makes it possible to run with strict transaction control or with ultra-fast transactionless disk access, whichever is most appropriate for the situation.

PHP
Site: http://www.php.net/
Documentation: http://www.php.net/manual/en/
Download: http://www.php.net/downloads.php (Latest stable version of PHP - Windows Binaries - Zip version not installer Example: PHP 4.3.2 zip package)
PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.

Apache
Site: http://httpd.apache.org/
Documentation: http://httpd.apache.org/docs/
Download: http://httpd.apache.org/download.cgi (Latest version of Apache Windows Version 1.3.xx - Win32 Binary (MSI Installer) EX: Apache 1.3.28)
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.Apache has been the most popular web server on the Internet since April of 1996. The July 2003 Netcraft Web Server Survey found that 63% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined.

phpMyAdmin
Site: http://www.phpmyadmin.net
Download: http://www.phpmyadmin.net/ (Downloads Section)
phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the WWW. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields.

Optional Downloads
The following is a list of the optional conponents for your system.
Zend Optimizer
Site: http://www.zend.com/store/products/zend-optimizer.php
Download: http://www.zend.com/store/products/zend-optimizer.php (Free Download)
The Zend Optimizer is a free application that runs the files encoded by the Zend Encoder and Zend SafeGuard Suite, while enhancing the running speed of PHP applications.

Development Tools
The following is a list of development tools that will help you a great deal. If you already have your favorites then stay with them, this is a list of my favorites.

FileZilla
Site: http://filezilla.sourceforge.net/
Documentation: http://filezilla.sourceforge.net/documentation/
Download: http://sourceforge.net/project/showfiles.php?group_id=21558 (Newest Version)
FileZilla is a fast FTP client for Windows with a lot of features. FileZilla Server is a reliable FTP server.

WebDrive
Site: http://www.webdrive.com/products/webdrive/index.html
Documentation: http://www.webdrive.com/support/webdrive/webhelp/webdrive.htm
Download: http://www.webdrive.com/download/index.html (Newest Version)
WebDrive is not free, but in my opinion is one of the greatest time saver tools I have for web development. This tool allow you to map a remote FTP drive to your local drive letter. This allows you to edit files live while online. No more download, modify, upload, view, etc..WebDrive integrates your web or FTP server into the Windows file system by mapping it to a drive letter. This enables you to connect to the server and perform familiar file operations like copy, move, and directory functions with the Windows explorer. Using simple drag and drop, you can transfer individual or multiple files - even entire directory structures. WebDrive offers FTP client functionality that's feature-rich and easy to use.

PuTTY
Site: http://www.chiark.greenend.org.uk/~sgtatham/putty/
Documentation: http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html
Download: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html (Newest Version)
PuTTY is a free implementation of Telnet and SSH for Win32 platforms, along with an xterm terminal emulator. It is written and maintained primarily by Simon Tatham.

Shell Utils
Download: shell_tools.zip
This is a collection of shell tools that allow you to type unix style commends on your win32 system. While it is allways recommended you use the build in functions of PHP, there are times when you need to make a shell call. These tools will allow the command to run and will preform the task correctly (if applicable), and if not (ex: chmod) will not return an error.

TortoiseCVS
Site: http://www.tortoisecvs.org/
Documentation: http://www.tortoisecvs.org/support.shtml
Download: http://www.tortoisecvs.org/download.shtml (Stable Version)
This software is ONLY valuable if you are developing using a CVS server.TortoiseCVS is an extension for Microsoft Windows Explorer that makes using CVS fun and easy. Features include: coloured icons, tight integration with SSH, and context-menu interactivity.

7-Zip
Site: http://www.7-zip.org/
Documentation: http://www.7-zip.org/support.html
Download: http://www.7-zip.org/download.html (7-Zip for Windows 98/ME/NT/2000/XP)
I do not use this program, I use WinZip but this is a free product so I am listing it.7-Zip is a file archiver with the highest compression ratio. The program supports 7z, ZIP, RAR, CAB, GZIP, BZIP2 and TAR formats. Compression ratio in the new 7z format is 30-50% better than ratio in ZIP format. 7-Zip has powerful command line version.

WinSCP
Site: http://winscp.sourceforge.net/eng/index.php
Documentation: http://winscp.sourceforge.net/eng/docs/
Download: http://winscp.sourceforge.net/eng/download.php (Latest Version)
This is a great and secure alternative to FTP. WinSCP is an open source SFTP client for Windows using SSH. Legacy SCP protocol is also supported. Its main function is the safe copying of files between a local and a remote computer. Beyond this basic function, WinSCP manages some other actions with files.

Install MySQL
Installing MySQL should be very quick and painless. The install program should take care of everything you need.

The MySQL database server is the world's most popular open source database. Its architecture makes it extremely fast and easy to customize. Extensive reuse of code within the software and a minimalistic approach to producing functionally-rich features has resulted in a database management system unmatched in speed, compactness, stability and ease of deployment. The unique separation of the core server from the storage engine makes it possible to run with strict transaction control or with ultra-fast transactionless disk access, whichever is most appropriate for the situation.

The MySQL database server is available without a license fee under the GNU General Public License (GPL). Commercial non GPL licenses are available for users who prefer not to be restricted by the terms of the GPL.

  1. Unzip the install file. EX: c:\disks\mysql\mysql-4.0.14b-win.zip
  2. Run setup.exe (leave destination c:\mysql, unless you want to move it.)
  3. Select Typical install, or custom if you wish to see / change options
  4. Let Install finish.
  5. Run c:\mysql\bin\winmysqladmin.exe, and set your username and password for this tool. This will start the mysql service.
  6. Reboot your computer
  7. Open 'Services' located in control panel Administrative Tools. You will should see mysql listed.
  8. Open a command prompt Start Programs Accessories Command Prompt
  9. Change Directory to the MySQL bin directory (c:\mysql\bin\)
  10. We are not going to change your root passwordType mysqladmin -uroot password ex: mysqladmin -uroot password secret.Make a note of this password. It will be your superuser root access password for MySQL.

You are all finished installing MySQL !!

Install PHP
We will now install and configure your PHP.

PHP is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The goal of the language is to allow web developers to write dynamically generated pages quickly.

PHP stands for PHP: Hypertext Preprocessor. This confuses many people because the first word of the acronym is the acronym. This type of acronym is called a recursive acronym.

  1. Unzip the install file. EX: c:\disks\php\php-4.3.2-Win32.zip
  2. Create the php directory c:\php
  3. Copy the contents of the zip file into c:\php, the php.exe program should be in c:\php\
  4. Copy the contents of the dll directory to your system32 directory (ex: c:\winnt\system32)
  5. Copy 'php4ts.dll' to your system32 directory (ex: c:\winnt\system32)
  6. Copy c:\php\php.ini-dist to c:\php\php.ini and open this file in a text editer.
  7. Locate the section for "Paths and Directories" and change the ;include_path = to 'include_path = ".;/php/pear"'
    This will set the path for PHP to look for files. First it will look in the current directory and this will also allow you to use PEAR tools.
  8. Locate the 'register_globals' variable and insure it is set to 'register_globals = On'. NOTE: For a production server it is safer to have this set to off, but for development I have found many times that other programmers do not code for this, so I must keep it on.
  9. Locate the 'extension_dir' variable and insure that it is set to 'extension_dir = C:/php/extensions/', this will allow PHP to find the extentions.
  10. Locate the 'SMTP' varable and modify this to your needs. This is the server that will send out emails in PHP. In most cases you can set this to you mail server for your web host, in other cases you may need to set this to the server of your ISP.
  11. Move c:\php\php.ini to your windows directory ex: c:\winnt

You are all finished installing PHP!!

Install Apache
We will now install and configure your Apache.

The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

Apache has been the most popular web server on the Internet since April of 1996. The July 2003 Netcraft Web Server Survey found that 63% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined.

  1. Run the install program located in your download directory (ex: c:\disks\apache\apache_1.3.28-win32-x86-no_src.msi)
  2. When prompted for 'Server Information' enter the name of the computer in the domain and server names. Enter your email address in the email address line.
    If you are unsure of your computer name you should find it in your 'Network Identification' tab of your system properties
  3. Select 'Complete' for the install type.
  4. You should now see Apache listed in your services.
  5. To test your install open a browser and enter the address 'http:///' and you will see a welcome page from apache. ex: (http://my-computer/)
  6. Create a working directory for web sites. If you work with only one server you can have this match the live server you use, or you can set your own. I use c:\www this way I can backup one directory and have all my working web sites. ex: (c:\www)
  7. Open the httpd.conf file in your apache install directory. (C:\Program Files\Apache Group\Apache\conf)
    This file control your web server and allows you to create web sites. We will simply update your working directory.
    Locate 'DocumentRoot' and update this to your web root directory we just created. ex:
    DocumentRoot "C:/www"
    Locate

    Directory "C:/Program Files/Apache Group/Apache/htdocs"

    and update this to match the same as above. ex:

    Directory "C:/www"

    Locate 'DirectoryIndex' and add 'index.php, index.php3' the end of the line. (ex: DirectoryIndex index.php, index.php3, index.html)
  8. At the very bottom of this file add the following lines.

    # Load PHP & USE vhost.conf for domains
    LoadModule php4_module "C:\php\sapi\php4apache.dll"
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php3
    #include conf/vhost.conf

    This section will tell Apache to process all .php & .php3 files through PHP and in advanced features we can setup new domains on this web server. You can add different extensions for PHP if you wish, but for now this should work.
  9. From your 'Services' program restart Apache. NOTE: All changes to php.ini or httpd.conf REQUIRE your to restart apache for them to go into effect.
  10. Create a file named 'phpinfo.php' in your new web root (ex: c:\www) and add the following code to the file. This program will help you to text and find important information your server.


    Point your browser to http://your_server_name/phpinfo.php and you should see the phpinfo screen. This will tell you that you have apache working with PHP.

Congratulation you are all finished installing Apache!!

Install phpMyAdmin
Installing phpMyAdmin should be very simple and will test to insure PHP, MySQL, and Apache are all talking.

phpMyAdmin is a tool written in PHP intended to handle the administration of MySQL over the WWW. Currently it can create and drop databases, create/drop/alter tables, delete/edit/add fields, execute any SQL statement, manage keys on fields.

  1. Unzip the install file. EX: c:\disks\phpmyadmin\phpMyAdmin-2.5.3-rc2-php.zip
  2. Create a directory in your web root named 'phpMyAdmin'. I recommend keeping the same case as listed as modt live web servers do as well. (ex: c:\www\phpMyAdmin\).
  3. Copy the contents of the zip into this new folder.
  4. Edit the c:\www\phpMyAdmin\config.inc.php file and modify

    $cfg['Servers'][$i]['password']='';

    to

    $cfg['Servers'][$i]['password']='YOURPASSWORDHERE';

    This is the password your created when intalling MySQL.
  5. Point your browser to http:///phpMyAdmin/ (ex: http://my-computer/phpMyAdmin/)

You are all finished installing phpMyAdmin !!

Resource Links
These links have been invaluable resources and are my favorites.
*** HotScriptsHotScripts is one of the best resources for open source PHP code.
*** SourceForgeSourceForge is one of the best resources for all types of open source code.
*** PHP ClassesPHP Classes has a great resource of Open Source PHP classes.

Help & Tutorial Links

Developer ShedDevShed has a user run forum.

Copyright © 2003 Amalla International, All rights reserved.
http://www.amalla.com/

Wednesday, February 09, 2005

This is some good general linux information... Not php, but very useful...

Title Detecting hardware from outside the box
Date 2005.02.02 10:07
Author Beret
Topic
http://enterprise.linux.com/article.pl?sid=05/02/02/159213
Linux comes with several good utilities for getting detailed information on what's inside the box. Here are three recipes for getting information from lspci, dmesg, and /proc.


This article is excerpted from the recently published book "The Linux Cookbook."

Detecting hardware with lspci

You're looking at new systems, or installing Linux on a box that used to run a different OS, and you're wondering if all the components -- video, modem, Ethernet, sound -- will work on Linux. The vendors can't, or won't, tell you if their products will work on Linux. You need to know what the chipsets are, to find out if there are Linux drivers.

Alternatively, you want to know what components are installed inside a computer, and you don't feel like hauling the thing out, popping the case open, and tearing it apart.

Solution: Use lspci:

# /sbin/lscpi# /sbin/lspci -v# /sbin/lspci -vv

To show a summary of all devices connected to the PCI bus, use:

$ /sbin/lspci
00:00.0 Host bridge: VIA Technologies, Inc. VT8363/8365 [KT133/KM133] (rev 02)
00:01.0 PCI bridge: VIA Technologies, Inc. VT8363/8365 [KT133/KM133 AGP]
00:06.0 Ethernet controller: Linksys Network Everywhere Fast Ethernet 10/100 model NC100 (rev 11)
...

Use the -v or -vv flags to display more information:

# /sbin/lspci -v
0000:01:00.0 VGA compatible controller: 3Dfx Interactive, Inc. Voodoo 3 (rev 01) (prog-if 00 [VGA])
Subsystem: 3Dfx Interactive, Inc.: Unknown device 1252
Flags: 66MHz, fast devsel, IRQ 10
Memory at d4000000 (32-bit, non-prefetchable) [size=32M]
Memory at d8000000 (32-bit, prefetchable) [size=32M]
I/O ports at c000 [size=256]
Expansion ROM at [disabled] [size=64K]
Capabilities: [54] AGP version 1.0
Capabilities: [60] Power Management version 1

If you're looking for drivers, you can now take this output (e.g., VT8363/8365 or 3Dfx Interactive, Inc. Voodoo 3 (rev 01)) to run a Google search.

lspci reads some information from the PCI bus, then displays additional information from its own database of hardware IDs -- vendors, devices, classes and subclasses -- at /usr/share/misc/pci.ids. There is even a command to update this file:

# update-pciids

The lspci maintainers welcome submissions of new data; please read /usr/share/misc/pci.ids for how to make submissions.

If there is a device attached to the system that the lspci simply does not recognize, such as a very old, odd ISA device, you'll have to open the case to see what it is. Or try running dmesg (Recipe 5.3).

Using dmesg to collect hardware information

PCI is fine, but it's yesterday's news; you need an inventory of all the devices on the system, not just PCI devices. You're interested in USB devices, SCSI devices, memory configuration, even the CPU.

Solution: Use dmesg. dmesg is a record of everything detected by the kernel.

To view all dmesg output, use:

$ dmesg less

You can also filter the output of dmesg to find specific devices. For example, to list all USB devices, use:

$ dmesg grep -i usb

To list ISA devices, use:

$ dmesg grep -i isa
isapnp: Scanning for PnP cards...
isapnp: SB audio device quirk - increasing port range
isapnp: Card 'SupraExpress 56i Voice'

To see how much physical memory is on the system, use:

$ dmesg grep -i memory
Memory: 256492k/262080k available (1467k kernel code, 5204k reserved, 516k data, 96k init, 0k highmem)

This shows IDE devices using the SCSI emulation subsystem, which is used on 2.4 and older kernels:

$ dmesg grep -i scsi
Kernel command line: root=/dev/hda6 ro hdb=scsi hdc=scsi
ide_setup: hdb=scsi
ide_setup: hdc=scsi
SCSI subsystem driver Revision: 1.00
hdb: attached ide-scsi driver.
hdc: attached ide-scsi driver.
scsi0 : SCSI host adapter emulation for IDE ATAPI devices
...

Here are what "real," not emulated, SCSI devices look like:

$ dmesg grep -i scsi
SCSI subsystem driver Revision: 1.00
scsi0 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.8

aic7892: Ultra160 Wide Channel A, SCSI Id=7, 32/253 SCBs
...Vendor: IBM-PSG Model: DPSS-336950M M Rev: S9HA
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
(scsi0:A:0): 160.000MB/s transfers (80.000MHz DT, offset 63, 16bit)
SCSI device sda: 71096640 512-byte hdwr sectors (36401 MB)
Partition check:
sda: sda1 sda2 sda3 sda4 <>

Shown here is information about a USB camera that is connected to the system, including its location in the filesystem. Typically, USB output runs to a dozen lines or more:

$ dmesg grep -i usb
...
usb.c: registered new driver ibmcam
ibmcam.c: IBM PC Camera USB camera found (model 2, rev. 0x030a)
usbvideo.c: ibmcam on /dev/video0: canvas=352x240 videosize=352x240

To show serial ports, use:

$ dmesg grep -i tty
ttyS00 at 0x03f8 (irq = 4) is a 16550A

To show CPU or CPUs, use:

$ dmesg grep -i cpu
Initializing CPU#0
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 64K (64 bytes/line)
Intel machine check reporting enabled on CPU#0.
CPU: After generic, caps: 0183f9ff c1c7f9ff 00000000 00000000
CPU: Common caps: 0183f9ff c1c7f9ff 00000000 00000000
CPU: AMD Duron(tm) Processor stepping 01

Note that these searches only return lines containing your search string. There is often more information adjacent to these lines, which you'll find by eyeballing the whole file:

Initializing CPU#0
Detected 801.446 MHz processor.

dmesg always provides up-to-date information, even if you're changing hardware frequently (for example, plugging in and detaching hotplug USB devices).

Getting live hardware snapshots with /proc

You want to monitor a running system in real time, and view things like physical memory and CPU information, or identify drives.

Solution: Read the /proc virtual filesystem. Use only cat to read /proc, or utilities designed expressly for it, such as sysctl, lspci, ps, and top. The syntax is the same as for reading any file:

$ cat /proc/filename

You can explore /proc just like any filesystem and easily find the information you want. Look to the named folders for hardware information:

$ ls /proc
bus cmdline cpuinfo devices dma driver filesystems ide kcore kmsg ksyms loadavg
meminfo misc modules mounts mtrr partitions pci scsi swaps sys tty

For example, to show CPU information, use:

$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 3
model name : AMD Duron(tm) Processor
stepping : 1
cpu MHz : 801.442
...

To show physical memory and swap usage, use:

$ cat /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 262746112 237740032 25006080 0 11575296 150138880
Swap: 534601728 81661952 452939776
MemTotal: 256588 kB
MemFree: 24420 kB
...

To tell all about an IDE hard drive, use:

$ cat /proc/ide/via
-------VIA BusMastering IDE Configuration---------
Driver Version: 3.37
South Bridge: VIA vt82c686a
Revision: ISA 0x22 IDE 0x10
Highest DMA rate: UDMA66
BM-DMA base: 0xd400
PCI clock: 33.3MHz
...

To see disk geometry, both real and logical, use:

$ cat /proc/ide/ide0/hda/geometry
physical 39870/16/63
logical 2501/255/63

To identify a drive, use:

$ cat /proc/ide/ide0/hda/model
IBM-DTLA-305020

To show driver versions for all IDE drivers, use:

$ cat /proc/ide/drivers
de-scsi version 0.93
ide-cdrom version 4.59-ac1
ide-floppy version 0.99.newide
ide-disk version 1.17
ide-default version 0.9.newide

To show capabilities of CD drives, use:

$ cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.12 2000/10/18
drive name: sr1 sr0
drive speed: 40 32
...
Can read multisession: 1 1
Can read MCN: 1 1
Reports media changed: 1 1
Can play audio: 1 1
Can write CD-R: 1 0
Can write CD-RW: 1 0
Can read DVD: 0 1
Can write DVD-R: 0 0
Can write DVD-RAM: 0 0

To show SCSI devices, using the following command. Note that it does not differentiate between devices attached to the SCSI bus and IDE devices using the SCSI-emulation subsystem. These are IDE CD drives:

$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: TOSHIBA Model: DVD-ROM SD-M1202 Rev: 1020
Type: CD-ROM ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: LITE-ON Model: LTR-24102B Rev: 5S54
Type: CD-ROM ANSI SCSI revision: 02

For AMD Users
Since AMD went to "performance ratings," instead of plain ole gigahertz, CPU ratings can be confusing. Your shiny new Athlon 3200 won't appear in /proc/cpuinfo as "cpu MHz 3200" -- instead, it will be something like 2800. You're not being ripped off; that's a result of how AMD chooses to rate the performance of their processors. In a nutshell, they claim that clock speed alone is not an accurate measure of performance, so they devised a different scale that more accurately reflects the CPU's true abilities. Visit http://www.amd.com for details.

On the other hand if your Pentium 3200 shows up in /proc/cpuinfo as a number other than 3200, there is a problem, because Intel uses the literal clock speeds.

This following command is just plain fun and has absolutely no practical value. It requires a functioning sound system. Warning: it's noisy -- this is the sound of your CPU in action. Ctrl-C stops it:

# cat /proc/kcore > /dev/dsp
Disk geometry, as expressed by /proc or any other utility, is largely a fiction. Modern drives are far more complex than the old "heads sectors cylinders" model.

As mentioned earlier, to read /proc use only cat or utilities designed expressly for it, such as sysctl, lspci, ps, and top. Pagers like less and more give a different picture, because they re-read /proc with each page. And you don't want to use a text editor, or any utility with write powers, because you can mess up your system in a heartbeat.


Links

--------------------------------------------------------------------------------


"The Linux Cookbook" - http://%0D%0Aservice.bfast.com/bfast/click?bfmid=2181&sourceid=39391960&isbn=0596006403
"http://www.amd.com" - http://www.amd.com/

Monday, February 07, 2005

I thought i'd like writing about programming, but since i do it all day long at work, it's kinda boring... sorry folks...