By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

IIS and Apache to serve one PHP page?

P: n/a
Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server. This setup was used, according to my understanding, for
security reasons.
Throughout my PHP scripts, I use connection code similar to the
following, which has worked fine for me on a
web server->database server test system:

$myServer = "testservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";

$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to Server.");

mssql_select_db($myDB, $conn)
or die("Couldn't connect to Server database.");

I have changed this code to something like the following for the
production system:

$myServer = "backendservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";

$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Could not connect to Server.");

mssql_select_db($myDB, $conn)
or die("Couldn't connect to server database.");

The problem is that we are receiving the "Could not connect to Server"
error. I.e., Apache is not switching over the processing of the PHP
page to the IIS server once the '$myServer = "backendservername";'
code is encountered. (Both the IIS and Apache have the same PHP codes
in their respective directories.)
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?
Thanks again for your assistance. I very much appreciate it,
Simon Gottesman

Aug 4 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Rik
On Sat, 04 Aug 2007 20:44:51 +0200, <sg*******@yahoo.comwrote:
Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server.
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?
Seems like unnecessary complication... If apache get's everything from
IIS, why not simply set up a proxy, and let IIS serve everything if that's
the main server....

--
Rik Wasmus
Aug 4 '07 #2

P: n/a
On Aug 4, 3:20 pm, Rik <luiheidsgoe...@hotmail.comwrote:
On Sat, 04 Aug 2007 20:44:51 +0200, <sgotte...@yahoo.comwrote:
Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server.
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?

Seems like unnecessary complication... If apache get's everything from
IIS, why not simply set up a proxy, and let IIS serve everything if that's
the main server....

--
Rik Wasmus- Hide quoted text -

- Show quoted text -
Do you mean using the mod_proxy Apache module?

Aug 4 '07 #3

P: n/a
sg*******@yahoo.com wrote:
Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server. This setup was used, according to my understanding, for
security reasons.
Throughout my PHP scripts, I use connection code similar to the
following, which has worked fine for me on a
web server->database server test system:

$myServer = "testservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";

$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to Server.");

mssql_select_db($myDB, $conn)
or die("Couldn't connect to Server database.");

I have changed this code to something like the following for the
production system:

$myServer = "backendservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";

$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Could not connect to Server.");

mssql_select_db($myDB, $conn)
or die("Couldn't connect to server database.");

The problem is that we are receiving the "Could not connect to Server"
error. I.e., Apache is not switching over the processing of the PHP
page to the IIS server once the '$myServer = "backendservername";'
code is encountered. (Both the IIS and Apache have the same PHP codes
in their respective directories.)
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?
Thanks again for your assistance. I very much appreciate it,
Simon Gottesman
THe only way processing will switch to the IIS server is if you load a
page containing PHP code on the IIS server or otherwise specifically
call PHP code on that other server. For that you need to be using
networking functions. Exactly which ones depend on your setup, and
every one is different.

Just setting a variable doesn't do a thing - other than set the variable.

And your connection is trying to connect to the mssql server at
"backendserver", not execute PHP code on that server.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 4 '07 #4

P: n/a
On Aug 4, 6:51 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
sgotte...@yahoo.com wrote:
Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server. This setup was used, according to my understanding, for
security reasons.
Throughout my PHP scripts, I use connection code similar to the
following, which has worked fine for me on a
web server->database server test system:
$myServer = "testservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";
$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to Server.");
mssql_select_db($myDB, $conn)
or die("Couldn't connect to Server database.");
I have changed this code to something like the following for the
production system:
$myServer = "backendservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";
$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Could not connect to Server.");
mssql_select_db($myDB, $conn)
or die("Couldn't connect to server database.");
The problem is that we are receiving the "Could not connect to Server"
error. I.e., Apache is not switching over the processing of the PHP
page to the IIS server once the '$myServer = "backendservername";'
code is encountered. (Both the IIS and Apache have the same PHP codes
in their respective directories.)
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?
Thanks again for your assistance. I very much appreciate it,
Simon Gottesman

THe only way processing will switch to the IIS server is if you load a
page containing PHP code on the IIS server or otherwise specifically
call PHP code on that other server. For that you need to be using
networking functions. Exactly which ones depend on your setup, and
every one is different.

Just setting a variable doesn't do a thing - other than set the variable.

And your connection is trying to connect to the mssql server at
"backendserver", not execute PHP code on that server.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Thanks for the reply Jerry.
Do you mean using PHP sockets?
Aug 5 '07 #5

P: n/a
sg*******@yahoo.com wrote:
On Aug 4, 6:51 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>sgotte...@yahoo.com wrote:
>>Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server. This setup was used, according to my understanding, for
security reasons.
Throughout my PHP scripts, I use connection code similar to the
following, which has worked fine for me on a
web server->database server test system:
$myServer = "testservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";
$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to Server.");
mssql_select_db($myDB, $conn)
or die("Couldn't connect to Server database.");
I have changed this code to something like the following for the
production system:
$myServer = "backendservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";
$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Could not connect to Server.");
mssql_select_db($myDB, $conn)
or die("Couldn't connect to server database.");
The problem is that we are receiving the "Could not connect to Server"
error. I.e., Apache is not switching over the processing of the PHP
page to the IIS server once the '$myServer = "backendservername";'
code is encountered. (Both the IIS and Apache have the same PHP codes
in their respective directories.)
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?
Thanks again for your assistance. I very much appreciate it,
Simon Gottesman
THe only way processing will switch to the IIS server is if you load a
page containing PHP code on the IIS server or otherwise specifically
call PHP code on that other server. For that you need to be using
networking functions. Exactly which ones depend on your setup, and
every one is different.

Just setting a variable doesn't do a thing - other than set the variable.

And your connection is trying to connect to the mssql server at
"backendserver", not execute PHP code on that server.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Thanks for the reply Jerry.
Do you mean using PHP sockets?

If your system is set up to use sockets, yes. But there could be a lot
of other ways to set it up, also - web pages on the IIS server and RPC
are two of them.

You need to find out how the admins set up this network before you can
get your code working.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 5 '07 #6

P: n/a
On Aug 4, 7:18 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
sgotte...@yahoo.com wrote:
On Aug 4, 6:51 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
sgotte...@yahoo.com wrote:
Hello,
If you could assist me with the following situation, I would be very
grateful.
In my current position, we have to use a non-traditional server setup
to serve PHP-generated web pages.
Instead of the classic web server->database server setup, what they
have at my workplace instead is:
Apache on a frontend server -needing to connect to IIS on a backend
server -needing to connect to SQL Server on the same backend
server. This setup was used, according to my understanding, for
security reasons.
Throughout my PHP scripts, I use connection code similar to the
following, which has worked fine for me on a
web server->database server test system:
$myServer = "testservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";
$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to Server.");
mssql_select_db($myDB, $conn)
or die("Couldn't connect to Server database.");
I have changed this code to something like the following for the
production system:
$myServer = "backendservername";
$myUser = "testuser";
$myPass = "testuserspassword";
$myDB = "dbName";
$conn = mssql_connect($myServer, $myUser, $myPass)
or die("Could not connect to Server.");
mssql_select_db($myDB, $conn)
or die("Couldn't connect to server database.");
The problem is that we are receiving the "Could not connect to Server"
error. I.e., Apache is not switching over the processing of the PHP
page to the IIS server once the '$myServer = "backendservername";'
code is encountered. (Both the IIS and Apache have the same PHP codes
in their respective directories.)
My questions:
1) Is this sort of setup workable? Has anyone successfully used a
similar setup to this in the past?
2) If so, how to do it? Can Apache be instructed to switch over
processing of PHP pages to the IIS on the other server via some sort
of Apache command? Is it instead some sort of programming issue that
I can fix by tweaking my code?
Thanks again for your assistance. I very much appreciate it,
Simon Gottesman
THe only way processing will switch to the IIS server is if you load a
page containing PHP code on the IIS server or otherwise specifically
call PHP code on that other server. For that you need to be using
networking functions. Exactly which ones depend on your setup, and
every one is different.
Just setting a variable doesn't do a thing - other than set the variable.
And your connection is trying to connect to the mssql server at
"backendserver", not execute PHP code on that server.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
Thanks for the reply Jerry.
Do you mean using PHP sockets?

If your system is set up to use sockets, yes. But there could be a lot
of other ways to set it up, also - web pages on the IIS server and RPC
are two of them.

You need to find out how the admins set up this network before you can
get your code working.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Thanks for the info,
I will look into it.

Aug 5 '07 #7

P: n/a
On Aug 4, 7:30 pm, sgotte...@yahoo.com wrote:
On Aug 4, 7:18 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:


sgotte...@yahoo.com wrote:
On Aug 4, 6:51 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>sgotte...@yahoo.com wrote:
>>Hello,
>>If you could assist me with the following situation, I would be very
>>grateful.
>>In my current position, we have to use a non-traditional server setup
>>to serve PHP-generated web pages.
>>Instead of the classic web server->database server setup, what they
>>have at my workplace instead is:
>>Apache on a frontend server -needing to connect to IIS on a backend
>>server -needing to connect to SQL Server on the same backend
>>server. This setup was used, according to my understanding, for
>>security reasons.
>>Throughout my PHP scripts, I use connection code similar to the
>>following, which has worked fine for me on a
>>web server->database server test system:
>>$myServer = "testservername";
>>$myUser = "testuser";
>>$myPass = "testuserspassword";
>>$myDB = "dbName";
>>$conn = mssql_connect($myServer, $myUser, $myPass)
>> or die("Couldn't connect to Server.");
>>mssql_select_db($myDB, $conn)
>> or die("Couldn't connect to Server database.");
>>I have changed this code to something like the following for the
>>production system:
>>$myServer = "backendservername";
>>$myUser = "testuser";
>>$myPass = "testuserspassword";
>>$myDB = "dbName";
>>$conn = mssql_connect($myServer, $myUser, $myPass)
>> or die("Could not connect to Server.");
>>mssql_select_db($myDB, $conn)
>> or die("Couldn't connect to server database.");
>>The problem is that we are receiving the "Could not connect to Server"
>>error. I.e., Apache is not switching over the processing of the PHP
>>page to the IIS server once the '$myServer = "backendservername";'
>>code is encountered. (Both the IIS and Apache have the same PHP codes
>>in their respective directories.)
>>My questions:
>>1) Is this sort of setup workable? Has anyone successfully used a
>>similar setup to this in the past?
>>2) If so, how to do it? Can Apache be instructed to switch over
>>processing of PHP pages to the IIS on the other server via some sort
>>of Apache command? Is it instead some sort of programming issue that
>>I can fix by tweaking my code?
>>Thanks again for your assistance. I very much appreciate it,
>>Simon Gottesman
>THe only way processing will switch to the IIS server is if you load a
>page containing PHP code on the IIS server or otherwise specifically
>call PHP code on that other server. For that you need to be using
>networking functions. Exactly which ones depend on your setup, and
>every one is different.
>Just setting a variable doesn't do a thing - other than set the variable.
>And your connection is trying to connect to the mssql server at
>"backendserver", not execute PHP code on that server.
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================- Hide quoted text -
>- Show quoted text -
Thanks for the reply Jerry.
Do you mean using PHP sockets?
If your system is set up to use sockets, yes. But there could be a lot
of other ways to set it up, also - web pages on the IIS server and RPC
are two of them.
You need to find out how the admins set up this network before you can
get your code working.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -

Thanks for the info,
I will look into it.- Hide quoted text -

- Show quoted text -
Hello again,
Could you help me with an example of how this could be done using the
technique mentioned above: web pages on the IIS Server.
Say, for instance, that my front end Apache Server has a page called
Employee.php that needs to display Employee data, like so:

$getEmployeeStmt = mssql_init("Sp_Get_EmployeeData");
mssql_bind($getEmployeeStmt, "@employeeNumber", $employeeNumber,
SQLVARCHAR, false);
$result = mssql_execute(getEmployeeStmt);
while($row = mssql_fetch_row($result))
echo "name: $row[0] <br />";

How could I use a web page sitting on the IIS server to get the
required information over to the Apache for this Employee.php page?
Thanks,
Simon

Aug 6 '07 #8

P: n/a
sg*******@yahoo.com wrote:
On Aug 4, 7:30 pm, sgotte...@yahoo.com wrote:
>On Aug 4, 7:18 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:


>>sgotte...@yahoo.com wrote:
On Aug 4, 6:51 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
sgotte...@yahoo.com wrote:
>Hello,
>If you could assist me with the following situation, I would be very
>grateful.
>In my current position, we have to use a non-traditional server setup
>to serve PHP-generated web pages.
>Instead of the classic web server->database server setup, what they
>have at my workplace instead is:
>Apache on a frontend server -needing to connect to IIS on a backend
>server -needing to connect to SQL Server on the same backend
>server. This setup was used, according to my understanding, for
>security reasons.
>Throughout my PHP scripts, I use connection code similar to the
>following, which has worked fine for me on a
>web server->database server test system:
>$myServer = "testservername";
>$myUser = "testuser";
>$myPass = "testuserspassword";
>$myDB = "dbName";
>$conn = mssql_connect($myServer, $myUser, $myPass)
> or die("Couldn't connect to Server.");
>mssql_select_db($myDB, $conn)
> or die("Couldn't connect to Server database.");
>I have changed this code to something like the following for the
>production system:
>$myServer = "backendservername";
>$myUser = "testuser";
>$myPass = "testuserspassword";
>$myDB = "dbName";
>$conn = mssql_connect($myServer, $myUser, $myPass)
> or die("Could not connect to Server.");
>mssql_select_db($myDB, $conn)
> or die("Couldn't connect to server database.");
>The problem is that we are receiving the "Could not connect to Server"
>error. I.e., Apache is not switching over the processing of the PHP
>page to the IIS server once the '$myServer = "backendservername";'
>code is encountered. (Both the IIS and Apache have the same PHP codes
>in their respective directories.)
>My questions:
>1) Is this sort of setup workable? Has anyone successfully used a
>similar setup to this in the past?
>2) If so, how to do it? Can Apache be instructed to switch over
>processing of PHP pages to the IIS on the other server via some sort
>of Apache command? Is it instead some sort of programming issue that
>I can fix by tweaking my code?
>Thanks again for your assistance. I very much appreciate it,
>Simon Gottesman
THe only way processing will switch to the IIS server is if you load a
page containing PHP code on the IIS server or otherwise specifically
call PHP code on that other server. For that you need to be using
networking functions. Exactly which ones depend on your setup, and
every one is different.
Just setting a variable doesn't do a thing - other than set the variable.
And your connection is trying to connect to the mssql server at
"backendserver", not execute PHP code on that server.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
Thanks for the reply Jerry.
Do you mean using PHP sockets?
If your system is set up to use sockets, yes. But there could be a lot
of other ways to set it up, also - web pages on the IIS server and RPC
are two of them.
You need to find out how the admins set up this network before you can
get your code working.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -
Thanks for the info,
I will look into it.- Hide quoted text -

- Show quoted text -

Hello again,
Could you help me with an example of how this could be done using the
technique mentioned above: web pages on the IIS Server.
Say, for instance, that my front end Apache Server has a page called
Employee.php that needs to display Employee data, like so:

$getEmployeeStmt = mssql_init("Sp_Get_EmployeeData");
mssql_bind($getEmployeeStmt, "@employeeNumber", $employeeNumber,
SQLVARCHAR, false);
$result = mssql_execute(getEmployeeStmt);
while($row = mssql_fetch_row($result))
echo "name: $row[0] <br />";

How could I use a web page sitting on the IIS server to get the
required information over to the Apache for this Employee.php page?
Thanks,
Simon
Simon,

This is way too setup-dependent. I could think of at least 20-30 ways
to do it - if not more.

You need to be talking with your sysadmins to see how they set things up.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 7 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.