• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Migrating Web Server from Nix to Windows

madmatt

Bow Down to the King
Political User
#1
We are in the process of migrating our web server from California to New York. During this transition we decided to go with Windows over Nix.

During testing I am receiving several errors with my mail scripts.

Here we go, showing one of each error:

PHP Notice: Use of undefined constant HTTP_CLIENT_IP - assumed 'HTTP_CLIENT_IP' in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 7
PHP Notice: Use of undefined constant REMOTE_ADDR - assumed 'REMOTE_ADDR' in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 11
PHP Notice: Use of undefined constant HTTP_USER_AGENT - assumed 'HTTP_USER_AGENT' in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 15
PHP Notice: Undefined index: contactContactName in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 17
Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 79
Not sure about the first three errors. I tried adding single quotes, but that didn't seem to work well.

if (getenv(HTTP_CLIENT_IP)) {
$ip = getenv(HTTP_CLIENT_IP);
}
else {
$ip = getenv(REMOTE_ADDR);
}

$hostname = gethostbyaddr($ip);
$client = getenv(HTTP_USER_AGENT);
For the fourth set of errors: We are using $_GET['variable'] but does not seem to be passing through.

$name = $_POST['contactContactName'];
For the last: I have no clue, is it related to the fourth set of errors?

$mailto = "matt@email.com";
$mailcc = "director@email.com";
$subject = "[walterelwoodmuseum.org] Incoming E-mail from ".$name;
$from = "From: $name <$email>\nCc: $mailcc\nReply-To: $email\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\n";
Thank you.
 
#2
do you need any windows specific hosting abilities?

If not, don't use windows for hosting. LAMP is much more stable and easier to fix when broken.
 

madmatt

Bow Down to the King
Political User
#6
Mark, I understand that and appreciate any and all input. The decision to move to Windows was made. The servers, software, and licensing were purchased by us through our vendor. The servers are being co-located at a datacenter that is nearby.

These PHP scripts all worked prior to the move therefore I think I am missing something that is necessary.

Again, I appreciate your input and I will ask more questions moving forward.
 

X-Istence

*
Political User
#8
1. IIS does not pass along that information as environment variables. That means you have to find a different way to get the same information. Stuff like

Code:
if (getenv(HTTP_CLIENT_IP)) {
$ip = getenv(HTTP_CLIENT_IP);
}
else {
$ip = getenv(REMOTE_ADDR);
}

$hostname = gethostbyaddr($ip);
$client = getenv(HTTP_USER_AGENT);
will NOT work on IIS. You need to look into using the $_SERVER superglobal as said on the page that LordofLA also linked to:

http://uk2.php.net/manual/en/reserved.variables.server.php

getenv() works on Windows, to get Windows environment variables, but the ASAPI API used to hook into IIS does not set environment variables on the fly. Check a file with just phpinfo(); in it to see what it does send to PHP scripts for you to use.

2. Next up, your error about the $_POST variable not existing, add a debug line of code that reads as such:

Code:
print_r($_POST);
Somewhere near the top, re-run the page and take a look at the source code your browser gets. It will contain a dump of the $_POST variable.

3. As for your mail command, your $from line contains \n. According to the RFC's you need to use \r\n, sendmail and friends (only one that refuses is qmail) will happily accept the malformed email and send it, your new server may not be so lenient. Please add \r\n instead of \n. Also, please show us your mail() command you are using to send out the email.

PHP on IIS:
Now, as for PHP on IIS, I suggest you open up a new Visual Studio window, and start writing some ASP .NET code in C# to replace all PHP code. I agree with Geffy on this one, PHP on IIS is the worst experience EVER. Before a choice like moving from Nix to Windows was made such things should have been considered. I have written my fair share of PHP projects, and I have had clients try to run it on Windows, it is an unsupported configuration. PHP on Windows even with Apache and mod_php is a nightmare.
 

madmatt

Bow Down to the King
Political User
#9
All issues were fixed as of 11:30 PM/ET last night. The migration (web was uploaded the day before, email was first yesterday, DNS, name servers) started at 5:00 PM.

I plan on converting all code over to ASP, but it's going to take time.

The problem with mail() was it didn't like From: $name <$email>, I had to change it to From: <$email> and it worked fine.

Thank you, I will make some of these changes for the shortterm.
 

Members online

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,013
Latest member
Pdawgintown