WAMP set up and configuration tips

Random collection of simple reminder tips and tricks on kicking up a WAMP setup for website development. Could work for a LAMP setup, if you're using Linux instead of Windows. Consider your own variants on folder locations and naming standards when reading.

Windows

Not much really to touch with the Windows section, unless not having to work with files outside of defaults. Happens. Just the way people are.

localhost alias

http://localhost/ happens to be the default go to address for the development site. There are times, or coding preferences, in working with an address in the location bar to work with a faux TLD. Maybe something like http://foo.com/ to your wardrobe. Also happens to be quicker to type than localhost when using the auto-complete command of CTRL + Enter. So just rename it.

On a Windows XP/Vista system, fire up C:\Windows\system32\drivers\etc\hosts in a text editor and insert the following lines.

127.0.0.1    foo.com
127.0.0.1    www.foo.com

Doesn't matter about the second line really, the one with the leading www. Doesn't hurt either.

Create a handy fire up batch process

This batch file will stop the currently running Apache and MySQL servers, delete any of the logs and then fire up the servers for a fresh restart.

net stop mysql
net stop apache2
del "C:\Program Files\Apache Group\Apache2\logs\access.log"
del "C:\Program Files\Apache Group\Apache2\logs\error.log"
net start apache2
net start mysql
exit

Save it into a file such as defib.bat and then just double-click it or call it on the command line when you're ready to restart the server or have made any changes to the configs to the various components. Swap out the names of mysql and apache2 if you have already set them other names.

Apache

Look for the httpd.conf in the following directory: C:\Program Files\Apache Group\Apache2\conf\ and get dirty playing with the configuration.

Using custom work folders

Not really a fan of using the install location of C:/Program Files/Apache Group/Apache2/htdocs as the place to look to when working on the sites in testing. Much prefer working on a dedicated drive with a close to base directory.

DocumentRoot "p:/randomecho"

Must also remember to update the next chunk with the same folder location as above.

<Directory "p:/randomecho">

.htaccess

Otherwise hidden, the .htaccess file allows for some funky configuration of the server. Cool schools like rules on URL rewriting (great for SEO) and access restrictions. On a Linux server, no problem seeing it, but might be a bit of a problem working on hidden files on a Windows system if you like associating files with certain programs.

Working on the htaccess with a filename such as htaccess.txt on Windows and then renaming it after uploading it onto the Apache server works plenty fine. In order for it to run properly on the Windows system, however, remember to put in a line such as this in httpd.conf

AccessFileName htaccess.txt

For the above to really work, look for the next section and switch it up to:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

Directory Index

Working with the default of index.html on directories is fine and all. But not for everybody.

DirectoryIndex index.php index.html

Unable to determine server name

Looking into the error.log file, if you find this line: httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.0.2 for ServerName then ServerName is either listening on the wrong port or the line itself is commented out. Fix that up below by changing the port to :80 or removing the hash that might be starting that line.

ServerName www.foo.com:80

Conflict with Comodo Antivirus

Works enough to not have Comodo Antivirus kibosh the running of the Apache server. Just add the following line into the httpd.conf file and it should now allow Apache to run normally.

Win32DisableAcceptEx

Serving PHP

Following fix up for Apache to serve PHP pages properly is pretty much automatically added when PHP 5 is correctly installed. If so, check for this chunk of config in the httpd.conf file to confirm Apache can handle PHP files.

#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:/PHP/"
LoadModule php5_module "C:/PHP/php5apache2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

RewriteEngine On

Before being able to fool around with the rewrite engine (major tool in working with SEO needs) enable it in the httpd.conf by looking for the Dynamic Shared Object Support section and removing the hash (#) before the module call.

# Dynamic Shared Object (DSO) Support
LoadModule rewrite_module modules/mod_rewrite.so

If you want to get knee-deep into the world of mod_rewrite, read Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

Trouble installing on Vista?

Paraphrasing from Installing Apache on Vista at Wyome.com:

Select Command Prompt from the Programs menu.
Right-click and select Run as administrator
Opens up the command prompt with admin rights.
Navigate to the directory of the saved apache*.msi install file
Type msiexec /i apache_2.2.8-win32-x86-openssl.msi (rename as needed)
Hit enter, and the rest should work just fine.

MySQL

Such a nice and serviceable database.

Add another user to access the database

Use this to set up an extra user by the name of say, monty, with all privileges, after the initial installation with the root user.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
	IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
	IDENTIFIED BY 'some_pass' WITH GRANT OPTION;

Chewing on more SQL than you can eat

Sometimes a database SQL import is so obese it takes more than just the small default 2MB to fill up the plate. Often the MySQL daemon will say something along the following if you're trying to import more than the dockyard will allow:

ERROR 2006 (HY000) at line 11805: MySQL server has gone away

Which basically means it got fed up trying to squeeze a watermelon through a cherry hole and walked off.

Look for the my.ini file in the MySQL install folder, say C:\Program Files\MySQL\MySQL Server 4.1\ and include the following line anywhere below the [mysqld] declaration. Suit as needed to accomodate SQL import files.

[mysqld]

max_allowed_packet = 16M

While you're here, set the default character set to something more flexible than the latin1. This will save you a lot of trouble and frustration if you set your database and pages as UTF-8 from the get go.

default-character-set=utf8

PHP

Squeeze out the php.ini onto a plain text editor. Depending on install settings, might be found in C:\PHP\ or some other directory. Pay attention when installing. Whatever was chosen, it's in the base folder of the PHP install files.

Dynamic extensions

Small things like playing with the GD library, MySQL connections or OpenSSL will need their respective options checked during the installation process (that .msi file for lazy Windows users) so as to allow the extensions to be enabled configure the php.ini file by dropping down to the Dynamic extensions section and edit thusly to flavour.

; Note that it should be the name of the module only; no directory information
; needs to go here.  Specify the location of the extension with the
; extension_dir directive above.
extension=php_mysql.dll
extension=php_gd2.dll
extension=php_curl.dll
extension=php_xmlrpc.dll
extension=php_openssl.dll

Remember that all of the above DLLs should be sitting in the folder set out in the extension_dir line earlier on.

; Directory in which the loadable extensions (modules) reside.
extension_dir ="C:\PHP\ext"

Unable to load dynamic library

There are times when one of the above DLLs fails to load. Most of the time it's a dependency issue.

For MySQL the problem usually stems from lonely php_mysql.dll file. Even though checking the extensions folder will show that that DLL is sitting plum and pretty, and the line in php.ini is correct, it's just not happy on its lonesome. As such, an error like the one below will pop up in the error log:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\PHP\\ext\\php_mysql.dll'
  - The specified module could not be found.\r\n in Unknown on line 0
And what's needed is to make sure the libmysql.dll file is sitting in the PHP installation folder. If the DLL is there then the error about not being able to load the MySQL library will be fixed. There is never a need to put anything in the system32 folder at all.

Massive file uploads

If massive equates to more than 2MB, then look for the following line and adjust the pant size accordingly.

; Maximum allowed size for uploaded files.
upload_max_filesize = 2MB

This will also be where you might be chock-blocked when importing an SQL file for such things as phpMyAdmin and you're told that the file you want to import is fatter than the jeans you want to slip into. As noted in the error:

No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.

Debugging

Problems and hiccoughs arise every now and then. Could be a missing colon, jamming in an array into a string only function or losing the keys to the database. Whatever it is, would be nice to see what the problem is instead of staring at a blank screen and having to fish for the error log every time. So make sure to turn on the display_errors variable to ease the pain of debugging and troubleshooting.

display_errors = On

 

Well, that's it. Don't forget to restart the server after the config changes.

Creative Commons License WAMP set up and configuration tips by Soon Van is licensed under a Creative Commons License.

Read up on the scope of the copyright.