Migrating Web Server from Nix to Windows

Discussion in 'Web Design & Coding' started by madmatt, Sep 12, 2008.

  1. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    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:

    Not sure about the first three errors. I tried adding single quotes, but that didn't seem to work well.

    For the fourth set of errors: We are using $_GET['variable'] but does not seem to be passing through.

    For the last: I have no clue, is it related to the fourth set of errors?

    Thank you.
     
  2. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    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.
     
  3. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    Too late for that. Everything has been purchased already.
     
  4. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    Most hosting providers will let you replace an order :)

    My current job invovles looking after some 40 odd linux webservers and 15 windows webservers (2003 and 2008). Windows does not make hosting easy or fun.

    Failing that take a look through http://uk2.php.net/manual/en/language.variables.superglobals.php for the answeres to your problems :)
     
  5. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    Oh and btw, you should come here and ask questions more often, atleast 2 of your moderators work in the hosting industry and can help you with details of said industry.
     
    madmatt likes this.
  6. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    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.
     
  7. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    Oh god, I can't begin to list the number of issues we've had with running PHP on IIS. I'd rather have teeth pulled.
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    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 likes this.
  9. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    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.