php-general Digest 30 Jan 2013 10:00:14 -0000 Issue 8105
Topics (messages 320114 through 320119):
Re: What needs to configure to run php exec for socket connection?
320114 by: tamouse mailing lists
320115 by: Ashley Sheridan
320116 by: jupiter
320117 by: jupiter
320118 by: Ashley Sheridan
error_log() bug on PHP 5.4.11?
320119 by: J.S.
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Sun, Jan 27, 2013 at 3:10 AM, jupiter <jupiter....@gmail.com> wrote:
> Hi,
>
> I have a client.php which calls an external python socket client
> program exec("Client.py"), the Client.py calls
> sockobj.connect(("localhost", 60000)) to connect socket.
>
> If I run the client.php from Linux command line $ ./client.php, it
> works find, no problem at all.
>
> But when I run it from web page http://localhost/client.php, it could
> not connect to socket at following exception in python
> sockobj.connect(("localhost", 60000)):
>
> "sockobj.connect Errno 13 Permission denied"
>
> Why it can run from command line, but cannot make socket connection
> from web? Does it need some kind of configuration in php or apache?
> Appreciate any tips and clues.
>
> Thank you.
>
> Kind regards.
> I am puzzled by
First question: why use a separate program and language to call a
socket? PHP has two ways of doing it, using the Socket extension and
using the Stream extension. The Stream extension is a little nicer as
you just use standard PHP file functions on it.
To look here, though, you might want to look at the permissions on
client.py to make sure it as well as the requisite paths to get to the
script are readable and executable by the user running your webserver,
or alternatively, your php scripts if running something like fcgi.
--- End Message ---
--- Begin Message ---
On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:
> On Sun, Jan 27, 2013 at 3:10 AM, jupiter <jupiter....@gmail.com> wrote:
> > Hi,
> >
> > I have a client.php which calls an external python socket client
> > program exec("Client.py"), the Client.py calls
> > sockobj.connect(("localhost", 60000)) to connect socket.
> >
> > If I run the client.php from Linux command line $ ./client.php, it
> > works find, no problem at all.
> >
> > But when I run it from web page http://localhost/client.php, it could
> > not connect to socket at following exception in python
> > sockobj.connect(("localhost", 60000)):
> >
> > "sockobj.connect Errno 13 Permission denied"
> >
> > Why it can run from command line, but cannot make socket connection
> > from web? Does it need some kind of configuration in php or apache?
> > Appreciate any tips and clues.
> >
> > Thank you.
> >
> > Kind regards.
> > I am puzzled by
>
> First question: why use a separate program and language to call a
> socket? PHP has two ways of doing it, using the Socket extension and
> using the Stream extension. The Stream extension is a little nicer as
> you just use standard PHP file functions on it.
>
> To look here, though, you might want to look at the permissions on
> client.py to make sure it as well as the requisite paths to get to the
> script are readable and executable by the user running your webserver,
> or alternatively, your php scripts if running something like fcgi.
>
I'll take a bet that the Apache server is running as a different user
from your login, and doesn't have permissions to open sockets. You could
either give the Apache user permissions, or put the exec call as part of
an argument of sudo.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On 1/27/13, tamouse mailing lists <tamouse.li...@gmail.com> wrote:
> On Sun, Jan 27, 2013 at 3:10 AM, jupiter <jupiter....@gmail.com> wrote:
>> Hi,
>>
>> I have a client.php which calls an external python socket client
>> program exec("Client.py"), the Client.py calls
>> sockobj.connect(("localhost", 60000)) to connect socket.
>>
>> If I run the client.php from Linux command line $ ./client.php, it
>> works find, no problem at all.
>>
>> But when I run it from web page http://localhost/client.php, it could
>> not connect to socket at following exception in python
>> sockobj.connect(("localhost", 60000)):
>>
>> "sockobj.connect Errno 13 Permission denied"
>>
>> Why it can run from command line, but cannot make socket connection
>> from web? Does it need some kind of configuration in php or apache?
>> Appreciate any tips and clues.
>>
>> Thank you.
>>
>> Kind regards.
>> I am puzzled by
>
> First question: why use a separate program and language to call a
> socket? PHP has two ways of doing it, using the Socket extension and
> using the Stream extension. The Stream extension is a little nicer as
> you just use standard PHP file functions on it.
I knew it was a bad example to run external python, so I tried to run
socket connection directly from the php file client.php, it got the
same error "socket_connect() failed. Reason: () Permission denied" at
$result = socket_connect($socket, "localhost", 60000).
Once again, it was fine to run the client.php from the command line. I
can feel something was missing either in php or apache ....
> To look here, though, you might want to look at the permissions on
> client.py to make sure it as well as the requisite paths to get to the
> script are readable and executable by the user running your webserver,
> or alternatively, your php scripts if running something like fcgi.
Forget about client.py, and all files are with 755 access permission.
It is not my first time to program and run php, but it is my first
time to run php file calling socket connection. Something was not
quite right here.
--- End Message ---
--- Begin Message ---
On 1/27/13, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:
>
>> On Sun, Jan 27, 2013 at 3:10 AM, jupiter <jupiter....@gmail.com> wrote:
>> > Hi,
>> >
>> > I have a client.php which calls an external python socket client
>> > program exec("Client.py"), the Client.py calls
>> > sockobj.connect(("localhost", 60000)) to connect socket.
>> >
>> > If I run the client.php from Linux command line $ ./client.php, it
>> > works find, no problem at all.
>> >
>> > But when I run it from web page http://localhost/client.php, it could
>> > not connect to socket at following exception in python
>> > sockobj.connect(("localhost", 60000)):
>> >
>> > "sockobj.connect Errno 13 Permission denied"
>> >
>> > Why it can run from command line, but cannot make socket connection
>> > from web? Does it need some kind of configuration in php or apache?
>> > Appreciate any tips and clues.
>> >
>> > Thank you.
>> >
>> > Kind regards.
>> > I am puzzled by
>>
>> First question: why use a separate program and language to call a
>> socket? PHP has two ways of doing it, using the Socket extension and
>> using the Stream extension. The Stream extension is a little nicer as
>> you just use standard PHP file functions on it.
>>
>> To look here, though, you might want to look at the permissions on
>> client.py to make sure it as well as the requisite paths to get to the
>> script are readable and executable by the user running your webserver,
>> or alternatively, your php scripts if running something like fcgi.
>>
>
>
> I'll take a bet that the Apache server is running as a different user
> from your login, and doesn't have permissions to open sockets. You could
> either give the Apache user permissions, or put the exec call as part of
> an argument of sudo.
Well, it is apache for both user id and group id if you are running
from web server. The problem is not which user account, I can run it
without any problems from command line in any user accounts, the
problem is it got permission denied when you run from web server.
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--- End Message ---
--- Begin Message ---
On Sun, 2013-01-27 at 21:40 +1100, jupiter wrote:
> On 1/27/13, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> > On Sun, 2013-01-27 at 03:45 -0600, tamouse mailing lists wrote:
> >
> >> On Sun, Jan 27, 2013 at 3:10 AM, jupiter <jupiter....@gmail.com> wrote:
> >> > Hi,
> >> >
> >> > I have a client.php which calls an external python socket client
> >> > program exec("Client.py"), the Client.py calls
> >> > sockobj.connect(("localhost", 60000)) to connect socket.
> >> >
> >> > If I run the client.php from Linux command line $ ./client.php, it
> >> > works find, no problem at all.
> >> >
> >> > But when I run it from web page http://localhost/client.php, it could
> >> > not connect to socket at following exception in python
> >> > sockobj.connect(("localhost", 60000)):
> >> >
> >> > "sockobj.connect Errno 13 Permission denied"
> >> >
> >> > Why it can run from command line, but cannot make socket connection
> >> > from web? Does it need some kind of configuration in php or apache?
> >> > Appreciate any tips and clues.
> >> >
> >> > Thank you.
> >> >
> >> > Kind regards.
> >> > I am puzzled by
> >>
> >> First question: why use a separate program and language to call a
> >> socket? PHP has two ways of doing it, using the Socket extension and
> >> using the Stream extension. The Stream extension is a little nicer as
> >> you just use standard PHP file functions on it.
> >>
> >> To look here, though, you might want to look at the permissions on
> >> client.py to make sure it as well as the requisite paths to get to the
> >> script are readable and executable by the user running your webserver,
> >> or alternatively, your php scripts if running something like fcgi.
> >>
> >
> >
> > I'll take a bet that the Apache server is running as a different user
> > from your login, and doesn't have permissions to open sockets. You could
> > either give the Apache user permissions, or put the exec call as part of
> > an argument of sudo.
>
> Well, it is apache for both user id and group id if you are running
> from web server. The problem is not which user account, I can run it
> without any problems from command line in any user accounts, the
> problem is it got permission denied when you run from web server.
>
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >
So you've logged on/sudo'd as the Apache user and the command runs?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hi,
When I call error_log() to log a message to the log file, I end up with
duplicate entries. Here is a minimal test script which reproduces the
problem for me:
<?php
ini_set('error_log', 'C:\Apache2\htdocs\myapp\app\logs\error_log');
error_log('some log message that, via a bug, will be logged twice');
?>
will log:
[30-Jan-2013 09:41:13 UTC] some log message that, via a bug, will be logged
twice
[30-Jan-2013 09:41:13 UTC] some log message that, via a bug, will be logged
twice
If it matters, I am running the VC9 x86 Thread Safe build of PHP 5.4.11 on a
Windows XP box but I had seen this problem in PHP 5.3.6 as well. I am
running Apache 2.2 for Web server.
Can somebody confirm whether this is a bug? I checked the bug database on
php.net but did not find anything relevant.
Best regards
J.S.
--- End Message ---