TUTORIAL: How to install PHP and MySQL on IIS

  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 20th, 2007, 7:25 am

nice tutorial.

I have an interesting problem and since you seem to have been really great in answering these fine people's questions, i thought I might pose it to you.

windows 2k3 standard server running iis = works fine
php is installed and working great.
mysql is installed on another server in the same domain and it is working great

i want to link the php install on the php machine to the mysql install ont he mysql machine.

i have the mysql.default_host = 192.168.1.141 (the server's ip on the network, i have also tried it's hostname) but when i open my test.php file to see what's installed and working in php, it does not list mysql at all.

ultimately i want to use phpmyadmin to manage the mysql install, but since my server running php can't see mysql, that isn't going to work yet.

so besides installing php on the mysql server, is there a way to get this setup to work?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 20th, 2007, 7:25 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: 28 May 2003
  • Posts: 20505
  • Loc: Pittsburgh PA
  • Status: Online

Post November 20th, 2007, 9:54 am

Never done that but just a hunch, you probably need to include the port msySQL is using, example 192.168.1.141:3306
Boasting Rights Sports Forums and Pools. NFL 2008-2009 pool is available now! Sign up and play for free in the Slingin' Sammy's NFL Pool forum!
Nuclear Services - www.alaron-nuclear.com
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 20th, 2007, 11:08 am

tried that, no dice. hmmm... i might try installing php on the mysql server just to ensure that that local installation can find the mysql using localhost.

I am having a hard time finding any documentation on how to troubleshoot a remote mysql connection like this though online.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: 28 May 2003
  • Posts: 20505
  • Loc: Pittsburgh PA
  • Status: Online

Post November 20th, 2007, 12:32 pm

Looks like this is how.
http://www.cyberciti.biz/tips/how-do-i- ... erver.html

Although the instructions assume a linux install, it looks like it should be relatively similar for Windows. I'll see if I can find a Windows version.


This guy got it to work in Windows:

http://forums.techguy.org/development/6 ... ccess.html
Boasting Rights Sports Forums and Pools. NFL 2008-2009 pool is available now! Sign up and play for free in the Slingin' Sammy's NFL Pool forum!
Nuclear Services - www.alaron-nuclear.com
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 20th, 2007, 1:30 pm

thanks for the info, I tried what that guy said, but there's no change.

I am wondering if what I am trying to accomplish is even worth it...

I have a database server i wanted to use for all of my SQL and MySQL dbs and an IIS server that would run websites with various languages like asp, php, etc. I was hoping that the php would link to MySQL on the other server to keep things uniform like that so I wouldn't have to put the MySQL dbs on the IIS server.

does this sound like a waste of time to you?

I kind of find it odd that I can't just define that mysql is at that specific location and php wouldn't jsut communicate with it, but then again, i am not an expert so...
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 21st, 2007, 5:53 am

update: interesting twist to the issue. on a hunch i tried to telnet from the IIS server to the database server on port 3306. it doesn't allow it. so there may be hope yet and it may lie in permissions. I'll keep digging and let you know.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: 28 May 2003
  • Posts: 20505
  • Loc: Pittsburgh PA
  • Status: Online

Post November 21st, 2007, 6:27 am

Check to make sure Window's firewall is NOT on. It will block it. I was reading a post yesterday with the same issue and all it was was the firewall. Once that was disabled everything worked peachy. (Sorry, had to leave quickly and didn't get to post or bookmark the page). If you use a 3rd party Firewall, make sure your Web Server is permitted.

Also if you use MySQL Administrator, log into it as root or an admin account and on the Startup section, General tab make sure "Disable Networking" is not checked. If it is, uncheck it and restart MySQL.
Boasting Rights Sports Forums and Pools. NFL 2008-2009 pool is available now! Sign up and play for free in the Slingin' Sammy's NFL Pool forum!
Nuclear Services - www.alaron-nuclear.com
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 21st, 2007, 6:44 am

both servers are win2k3 standard, neither using any firewall. local router with firewlal on it allows all lan to lan traffic. i think i originally configed this instance of MySQL with remote connection disabled. i am attempting to remove it and readd it with remote connection enabled.
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 21st, 2007, 7:57 am

did that. now telnet works. it didn't automatically show up in my php file, but i'll try some things and see what i can come up with. i really think this is supposed to be able to work.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: 28 May 2003
  • Posts: 20505
  • Loc: Pittsburgh PA
  • Status: Online

Post November 21st, 2007, 8:08 am

Yes it should work. I've just never done it so I'm guessing here.

In your php.config.ini how does this line read?

$cfg['Servers'][$i]['host'] = 'localhost';
Boasting Rights Sports Forums and Pools. NFL 2008-2009 pool is available now! Sign up and play for free in the Slingin' Sammy's NFL Pool forum!
Nuclear Services - www.alaron-nuclear.com
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 21st, 2007, 8:33 am

$cfg['Servers'][$i]['host'] = '192.168.1.141';

that's the ip of the database server

to tell you the truth though i am not even looking at phpmyadmin because php doesn't list mysql or when you do a

<?php
phpinfo();
?>

i am assuming that this issue needs to be fixed first and then phpmyadmin will fall into line after that.

i just don't get what i am missing.

I have extension=php_mbstring.dll and extension=php_mysql.dll unquoted in php.ini

extension_dir = ".\ext"

mysql.default_host = 192.168.1.141

the path to the php directory is set in windows... I'm not sure what else can be edited.

I also went to mysql and ran a
GRANT ALL PRIVILEGES ON *.* TO USERNAME@IP IDENTIFIED BY "PASSWORD"; supplying my root username and password to it.

thoughts?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: 28 May 2003
  • Posts: 20505
  • Loc: Pittsburgh PA
  • Status: Online

Post November 21st, 2007, 9:46 am

probably won't make a difference, but try adding the default port 3306 here around line 690

; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =


remember after making any changes to php.ini you should reboot. I've driven myself nuts over issues that I fixed but didn't realize I had until after I rebooted.
Boasting Rights Sports Forums and Pools. NFL 2008-2009 pool is available now! Sign up and play for free in the Slingin' Sammy's NFL Pool forum!
Nuclear Services - www.alaron-nuclear.com
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: 28 May 2003
  • Posts: 20505
  • Loc: Pittsburgh PA
  • Status: Online

Post November 21st, 2007, 9:50 am

Also from http://php.ftp.cvut.cz/manual/en/ref.mysql.php Try this I found in one of the comments:

[php]<? php
Following PHP Script is useful to test PHP connection with MySQL.
*/

//$connect = mysql_connect("Your Host Name", "MySQL root directory", 'MySQL password, if any');
//$connect = mysql_connect("Host Name or Address - 127.0.0.1", "root", 'password');
$connect = mysql_connect("localhost", "root", 'password');
if ($connect){
echo "Congratulations!\n<br>";
echo "Successfully connected to MySQL database server.\n<br>";
}else{
$error = mysql_error();
echo "Could not connect to the database. Error = $error.\n<br>";
exit();
}

// Closing connection
$close = mysql_close($connect);
if ($close){
echo "\n<br>";
echo "Now closing the connection...\n<br>";
echo "MySQL connection closed successfully as well.\n<br>";
}else{
echo "There's a problem in closing MySQL connection.\n<br>";
}
exit();
?>[/php]
Boasting Rights Sports Forums and Pools. NFL 2008-2009 pool is available now! Sign up and play for free in the Slingin' Sammy's NFL Pool forum!
Nuclear Services - www.alaron-nuclear.com
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 21st, 2007, 11:07 am

ATNO/TW wrote:
probably won't make a difference, but try adding the default port 3306 here around line 690

; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =


remember after making any changes to php.ini you should reboot. I've driven myself nuts over issues that I fixed but didn't realize I had until after I rebooted.


tried both, no change.

tried the php connect script but for some reason it is erroring out with unexpected T_VARIABLE
  • one2one
  • Novice
  • Novice
  • No Avatar
  • Joined: 20 Nov 2007
  • Posts: 19
  • Loc: Lancaster, PA
  • Status: Offline

Post November 21st, 2007, 11:40 am

wow...

i found the fix...

Add the following registry keys:

HKEY_LOCAL_MACHINE\SOFTWARE\PHP\5\IniFilePath -> c:\php5

that is... really... out there...

i'll see if i can get phpmyadmin working next.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 21st, 2007, 11:40 am

Post Information

  • Total Posts in this topic: 142 posts
  • Moderator: Moderator Team
  • Users browsing this forum: No registered users and 144 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 

Need a pre-made web design for your website?

Check out our templates here: Ozzu Templates