image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X Server

Reply
 
LinkBack Thread Tools
  #1  
Old March 30th, 2009, 05:08 AM
Registered User
 
Join Date: Mar 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
VirtualDarKness is on a distinguished road
Question PHP 5.2.6 + fsockopen on localhost

Hello,
on a Mac OS X Server 10.5 with PHP 5.2.6 i've a problem with an old php script:

Warning: fsockopen() [function.fsockopen]: unable to connect to 127.0.0.1:80 (Connection refused) in /path/to/script.php on line 54


I've tried to write a test script with the followin code:

Code:
<?php
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";

    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
?>
and it works correctly.. so the problems seems to happen when it tries to connect to localhost.

I've also tried to connect to 127.0.0.1 but got the same error.

any idea? should I change something in my php.ini?

thanks.

bye,
Giovanni.
Reply With Quote
  #2  
Old March 30th, 2009, 10:10 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 13,004
Thanks: 8
Thanked 444 Times in 425 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
Quote:
/path/to/script.php
Is this line taken verbatim out of the script you're trying to run, or are you using it as an example?

The reason I ask is that it looks like you've used some sample code that somewhere says "path/to/script.php" -- which isn't actually a valid path -- it's an example that's meant to be replaced with the actual path to some script file.
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 12Mb/1.5Mb
http://www.jeffhoppe.com
Reply With Quote
  #3  
Old March 30th, 2009, 11:04 AM
Registered User
 
Join Date: Mar 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
VirtualDarKness is on a distinguished road
Quote:
Is this line taken verbatim out of the script you're trying to run, or are you using it as an example?
hi,
thanks for your answer.

I wrote it that way as an example..

bye,
Giovanni.

p.s.
anyway that was the path to the script that returned the error message, not the file the script were trying to access to.
Reply With Quote
  #4  
Old March 30th, 2009, 11:19 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 13,004
Thanks: 8
Thanked 444 Times in 425 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
Ok, so I assume the basics are covered: that you're actually running a web server on port 80 and it's properly configured, yes?

What happens if you use "localhost" instead of "127.0.0.1"? What happens if you use the FQD of the server?
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 12Mb/1.5Mb
http://www.jeffhoppe.com
Reply With Quote
  #5  
Old March 31st, 2009, 04:07 AM
Registered User
 
Join Date: Mar 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
VirtualDarKness is on a distinguished road
Quote:
Originally Posted by ElDiabloConCaca View Post
Ok, so I assume the basics are covered: that you're actually running a web server on port 80 and it's properly configured, yes?
Yep, as I wrote I'm running Mac OS X Server 10.5 with PHP 5.2.6.

Quote:
What happens if you use "localhost" instead of "127.0.0.1"?
I still get the Connection refused error. It looks like it can't connect to itself.. Searching on google I found it could be a firewall problem but does Mac OS X server have a pre-installed firewall?

Quote:
What happens if you use the FQD of the server?
sorry.. what is the FQD?

thanks.

bye,
Giovanni.
Reply With Quote
  #6  
Old March 31st, 2009, 08:49 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 13,004
Thanks: 8
Thanked 444 Times in 425 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
Yes, both Mac OS X Client and Mac OS X Server come with a firewall -- in a default install, it's usually turned off, but you may want to check it. I would think that if you enabled Web Sharing that the proper ports would be automatically forwarded, but it never hurts to check:

http://www.apple.com/server/macosx/f...etworking.html

FQD = "Fully Qualified Domain" -- i.e., "myserver.com" or something like that. Basically, the domain name one would use to connect to the server from the "outside" world. It could also be something like "serverone.local" or something -- whatever you set up the name of the server to be when you installed Mac OS X Server.
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 12Mb/1.5Mb
http://www.jeffhoppe.com
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 02:00 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
Copyright 2000-2010 DigitalCrowd, Inc.