What inconsistencies should I expect between WAMP and LAMP stacks? [closed]
I am used to a LAMP (Linux, Apache, MySQL, PHP) stack, but occasionally I must use a WAMP (Windows ...) stack to meet certain client requirements.
I haven't run into any significant differences, but I'm seeing this requirement more and more, with applications that are becoming more demanding and complex.
- What should I watch out for between the two, or can I fully expect them to behave the same?
Please don't comment on the choice of stack or OS, I just need a list of gotchas moving from one to the other and vice versa.
-Adam
Solution 1:
The following come to mind:
- Case Sensitivity. Windows is case insensitive, while Linux is case sensitive.
- Path separator. Windows uses ";", Linux uses ":"
- Directory separator. Windows uses "\", Linux uses "/"
As far as directory separator goes, PHP has the DIRECTORY_SEPARATOR constant, I've found that always using the Linux variant "/" to be more convenient as it works in both Linux and Windows.
Solution 2:
Default settings are different in MySQL between the two platforms, particularly around case sensitivity of table names. Make sure you are perfect about either using all lower case table names, or always getting the case just right in the queries.
PHP's mail() function is quite a bit different under Windows from Linux. If you make heavy use of its features you should read the manual carefully. Many of the file system functions are also different because of system behaviors (like rename()). In general any function that interacts with the OS itself you will probably want to review the manual page for comments about behavior under Windows.
Solution 3:
There are a few configuration differences in php.ini. Like your extensions will be dlls, you'll need to setup a default smtp server instead of relying on sendmail. It is kind of obvious when reading through the ini file though. I've seen the WIMP combo run just fine in production (so WAMP will be that much smoother). So I'd say it is mostly setup and configuration and maybe the existence of some extensions.
Solution 4:
The directory separator thing has been mentioned, but an extra gotcha to watch out for:
On a LAMP machine, the separator is the same for both file system and web paths. On a LAMP machine, they're different. While this doesn't seem like it makes the situation much worse, I've dealt with more than a few web packages that discriminate between the file and web paths, but use the same separator constant for both (osCommerce, I'm looking at YOU.)
I've had lots of fun debugging that days after I thought I had all the path-insanity resolved.
Solution 5:
Above the other items mentioned above, I have noted that $_SERVER["DOCUMENT_ROOT"] trails with a slash on windows, and not on linux.
Not a large issue, with nested includes/rewriting or even just linking css/js you'll need to check for a trailing slash act accordingly.
just because it was handy :) - I have a pre-written function.
function docroot() {
$needle = '/';
$haystack = $_SERVER["DOCUMENT_ROOT"];
$length = strlen($needle);
$end = $length * -1; //negative
if (substr($haystack, $end) === $needle)
return $_SERVER["DOCUMENT_ROOT"];
else
return $_SERVER["DOCUMENT_ROOT"].'/';
}