how to install mysql and php on iis 6

Upload: pepet1000

Post on 06-Apr-2018

241 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    1/17

    How To Install MySQL and PHP on IIS 6.0

    posted in IIS 6.0, MySQL, PHP |

    In this walkthrough we are going to look at installing and configuring MySQL to work with

    PHP on an IIS 6.0 web server. If you have not already installed PHP you can do so byfollowing the steps in this article here (http://www.iisadmin.co.uk/?p=4)

    Installing MySQL on the Server

    Start by downloading MySQL. You can get the latest stable release version here :

    http://dev.mysql.com/downloads/mysql/5.0.html

    In this tutorial I am going to be using the Windows Essentials (x86) version which has all

    the core functionality you need to run a MySQL database server. Launch the mysql-

    essential-5.0.26-win32.msi installer file to start the MySQL Setup Wizard.

    Click Next and then choose a custom installation as this will allow us to specify aninstallation directory of our own choosing. In this example I will be using installing

    MySQL into the C:\MySQL folder.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    2/17

    On the Custom setup dialog box click Change to specify the preferred installation directory.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    3/17

    Select the directory you want to use and then click OK to go back to the Custom setup

    dialog box.

    Click next. MySQL is now ready to be installed. Click Install to begin the installation.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    4/17

    At the MySQL.com Sign Up screen click Skip Sign-Up and then click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    5/17

    On the next dialog box ensure that Configure the MySQL Server now tick box is checked

    and click Finish.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    6/17

    The Server Instance Configuration Wizard is now launched. Click Next to begin

    configuring your MySQL server.

    Choose Detailed Configuration and click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    7/17

    In this example I am installing MySQL on the same machine as my IIS web server so I opt

    for the Server Machine option. Choose a server type which is appropriate for yourrequirements and click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    8/17

    Choose the type of database which best suits your needs and click Next.

    Leave the default setting of the MySQL installation path for the InnoDB Tablespacesettings (unless you wish to change it) and click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    9/17

    Select the appropriate number of concurrent connections you want to allow and click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    10/17

    Leave the default networking options settings (unless you have reason to change them) and

    click Next.

    Choose the appropriate character set for your requirements and click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    11/17

    On the Windows options dialog box ensure that both Install As Windows Service and

    Include Bin Directory in Windows Path tick boxes are selected and click Next.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    12/17

    In the security options dialog box ensure that Modify Security Settings is ticked and type

    in your new root password. Decide whether or not you wish to allow root access fromremote machines or create an anonymous account and click Next.

    If you are happy with the choices you have made click Execute to begin configuring yourserver.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    13/17

    Once the Configuration Wizard has finished click Finish to begin using your new MySQL

    server.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    14/17

    Now that we have got MySQL installed we need to create a test user account which we will

    use later in this walkthrough to test connectivity to MySQL from a PHP script. Start byopening the MySQL Command Line Client. When prompted enter your root password and

    hit enter.

    T

    ype the following SQL command and hit enter :

    CREATE USER phptest@'localhost IDENTIFIED BY phptest;

    Then type this SQL command and hit enter :

    FLUSH PRIVILEGES;

    Now type this SQL command and hit enter :

    SELECT Host, User, Password FROM mysql.user;

    As you can see we have now created a new MySQL user account called phptest with a

    password of phptest. This user account can log in to MySQL but has not been granted anypermissions on any of the existing schema or databases.

    Configure PHP for MySQL Connectivity

    Now that we have got both PHP and MySQL installed on the server we can move on to the

    job of getting PHP connected to MySQL.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    15/17

    The first thing we need to do is enable the MySQL extensions for PHP to use. To do this

    locate the Dynamic Extensions section of your php.ini file and either uncomment or addthe following lines to the top of the existing list of extensions :

    extension=php_mbstring.dll

    extension=php_mysql.dll

    extension=php_mysqli.dll

    You may find that the line referencing php_mysqli.dll is not in your php.ini file - if not youwill need to add it to the list. Once you have done this save the changes in the php.inifile

    and then either recycle your PHP web sites application pool or perform an IISReset for thechanges to take effect. If you now browse the http://localhost/index.php file we created inthe first article you should see that support for MySQL is now enabled.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    16/17

    We are now ready to go ahead with a simple test script to ensure everything is setup

    correctly. Start by creating a new text file in Notepad in the root of your PHP test web siteand then type in the code shown here :

    Alternatively, you can download the file from here :

    http://www.iisadmin.co.uk/images/phpmysql/dbtest.zip

    Save the file as dbtest.php and then browse to http://localhost/dbtest.php on your server.You should see the error message shown below.

  • 8/3/2019 How to Install MySQL and PHP on IIS 6

    17/17

    This indicates two things. First, that we have successfully connected to MySQL from our

    test PHP script and second, that the user account we specified in our connection string doesnot have sufficient privileges to access the mysql system database.

    So you should now have a working installation of PHP and MySQL running on your IIS

    6.0 server. In the final article in this series I will demonstrate how to install WordPress onan IIS 6.0 web server.