Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Windows IIS / PHP 5 Installation Guide

Options
  • 04-07-2005 11:57am
    #1
    Registered Users Posts: 2,157 ✭✭✭


    Hey Guys,

    I was give the task of upgrading PHP 4 to PHP 5 this morning, which I felt was a fairly simple task. I was however suprised by the amount of niggly obstacles that landed in my path. Nothing too taxing, just frustrating when you have solved one problem only to be hit by another. Because of this, I have decided to put together a PHP 5 / IIS installation guide which hopefully will be of use to somebody out there. I also had to configure connectivity to a MySQL server which is normally standard fare, but you'll see the problem I hit at the end.

    The PHP.net installation instructions are actually pretty good. They detail the installation of PHP on a clean system (that is to say, a system that has never had PHP installed on it before). You can find the instructions here. Anyway, on to the guide.

    The first thing to do is to download the Windows PHP binary, which can be found here. Download the .zip package rather than the .exe installer. Create a folder to extract the .zip into. For this example I am going to use: c:\php\. Once the .zip has been extracted, add the folder to the PATH environment variable. You can do this by right clicking 'My Computer' and choosing 'Properties' (or Windows Key + Break) then choose Advanced -> Environment Variables. Choose Path under the System Variables section and click edit. Add c:\php\; at the end of the Variable value and keep clicking OK until all the windows disappear.

    You now need to set up the php.ini file. I'm not going to go into what you do and don't need in the file, for the moment just rename the file c:\php\php.ini-recommended to c:\php\php.ini. In PHP 5, MySQL is no longer built in so you need to remove the semi-colon from the line ;php_mysql.dll. (I took a look around for a web page that details the php.ini settings but I couldn't find a decent tutorial. If anyone finds a decent one post it and I'll edit it in. For now, try "A tour of the php.ini Part I and Part II").

    You now have the basics of PHP 5 installed. This is where I hit my first problem: The location of the php.ini file. I went to the command line and typed php -r phpinfo(); and it listed c:\windows as the location of my php.ini -- but there was no php.ini in there, how strange. Moving the php.ini to the Windows directory is a bit messy in my opinion so I decided to figure out how to point it to the folder I wanted to use. Taking a look at the PHP.net site it says that PHP looks for the php.ini in the following locations in order:
    - SAPI module specific location (PHPIniDir directive in 
      Apache 2, -c command line option in CGI and CLI, php_ini 
      parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)
    
    - HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry 
      location)
    
    - The PHPRC environment variable
    
    - Current working directory (for CLI)
    
    - The web server's directory (for SAPI modules), or directory of 
      PHP (otherwise in Windows)
    
    - Windows directory (C:\windows or C:\winnt) (for Windows), 
      or --with-config-file-path compile time option
    

    The Windows directory is the last place it looks, so obviously nothing above was meeting the criteria. I had added the PHP directory to the path but for some reason it wouldn't find it, so I opted to add the registry key (You need to create the key in SOFTWARE, then add a string value called IniFilePath with the value c:/php/). This worked fine.

    The next obstacle appeared when I tried to connect to a MySQL database. I had previously installed PHP 4 on the same machine which is significant. Whenever I tried connecting to a database it said: "Unable to load php_mysql.dll: Procedure does not exist". This stumped me for a while until I took a look at Loading PHP Extensions article on PHP.net. Someone noted that if you have previous versions of MySQL installed, you must remove the libMySQL.dll from the System32 directory before the PHP 5 MySQL will work. Once I removed the file PHP worked as expected.

    I know there's not a lot of new stuff in there but if it saves someone 5 minutes in the future then it will have been worth it.

    Serb


Comments

  • Closed Accounts Posts: 975 ✭✭✭squibs


    Yeah - I hit a bunch of other problems. I'll post them if I can remember them.


Advertisement