Here are the steps that I took to get PHP and MySQL on IIS:
Software Needed:
- IIS: Installed on all Windows
Servers and can be added to XP Pro via the Control Panel -> Add/Remove
Programs -> Add Windows Components.
- PHP: Can be downloaded from http://www.php.net/ (Be cure to get the
Windows Binaries Zip Package NOT the installer package)
- MySQL: Can be downloaded from http://www.mysql.com Choose the Community Server download. Also grab the GUI-Tools
Administrator while you are there.
- IZArc: If you do not have an unzip
tool this one is one of the best
PHP Install
Unzip the PHP binaries package (php-5.x.x-Win32.zip) to C:\PHP5 and do the following:
- Copy php.ini-recommended to C:\windows\ and rename to php.ini.
- Copy php5ts.dll to C:\windows\System32
Let IIS know you have PHP
You have to tell IIS where PHP is and add the extensions:
- Open
IIS control panel and expand the computer name to reveal "Web Sites" right
click to properties.
- Click
on the Home Directories tab and look for and click on the Configuration
button
- On the
Mappings tab click Add button, browse to C:\php5 and select php5isapi.dll. Then type .PHP in the extension field (Yes, type the period first)
- Next
go to the Documents tab and add index.php
as a new document and move it up to the top of the list.
- Add
C:\PHP5 to your system Path
- In a
cmd windows type PATH C:\PHP5;
%PATH%
Testing PHP
- Go to
your webroot folder (C:\Insetpub\wwwroot) and copy the following into a
newly created text file phpinfo.php:
<?PHP phpinfo(); ?>
- Open a
web browser and point it to http://localhost/phpinfo.php
You should see the PHP information page.
It contains all config variables that are loaded from the php.ini
file. If you see this page, PHP is
installed and configured.
MySQL Install
Unzip the MySQL file that you downloaded earlier and run
Setup.exe
- Choose
Compete Install and click NEXT till starts to copy files
- Choose
Configure the MySQL Server now
- Pick
Detailed Configuration
- Select
Server Machine
- Choose
Multifunctional Database
- Leave
the Default settings for InnoDB Tablespace
- Pick
Online Transaction Processing
- Leave
the networking options at the default settings
- Choose
Standard character set
- Check
Install as a service and include in to Path
- Modify
Security settings and choose a new root password
- Click
Execute to begin the configuration process
- Press
Finnish
Add a user to test with:
Open the SQL Administrator Command
Line and type the next commands (hit enter after each line)
CREATE USER 'test'@'localhost'
IDENTIFIED BY 'test';
FLUSH PRIVILEGES;
This will create a user called test
with a password of test
Bringing It All Together
Now we have to let PHP know that
MySQL has been install:
Open the php.ini file (Start ->
Run -> php.ini) and either uncomment or add the following:
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
Save the php.ini file and restart
IIS
Testing PHP & MySQL Together
Type the following in a text file and name it test.php
<?php
// Let's connect and select a
database
$link = mysql_connect('localhost',
'test', 'test')
or die('Couldn't connect to the MySQL Server:
' . mysql_error());
mysql_select_db('mysql') or
die('Couldn't Select the Database.<br><br>
The error returned by MySQL says:
<br>' . mysql_error());
// See Ya!
mysql_close($link);
?>
This page will comeback with the errors:
Couldn't Select the Database.
The error returned by MySQL says:
Access denied for user 'test'@'localhost' to database 'mysql'
This was just to see if PHP could see the MySQL Server. If you see this error it is install and
working.
Comments [0]