php-general Digest 28 Mar 2011 23:23:45 -0000 Issue 7248
Topics (messages 312087 through 312111):
Opensuse 11.4 - PHP returned as text?
312087 by: Colin Beckingham
312092 by: HallMarc Websites
312094 by: Colin Beckingham
312097 by: HallMarc Websites
Re: session variable problem
312088 by: markb
312089 by: Negin Nickparsa
Re: is there any syntax to save a file in mysql?
312090 by: Negin Nickparsa
312091 by: Negin Nickparsa
312093 by: Ashley Sheridan
Re: [PHP-WIN] Re: [PHP] Which versions of Apache will PHP 5.3.6 work with??
312095 by: Curtis Tammany
Re: opening a new window from php script
312096 by: Grega Leskovšek
312098 by: Ashley Sheridan
xinetd vs php socket server
312099 by: Nathan Nobbe
312102 by: Bostjan Skufca
312103 by: Nathan Nobbe
312105 by: Bostjan Skufca
312108 by: Nathan Nobbe
312110 by: Curtis Maurand
Re: Permission Denied
312100 by: Ethan Rosenberg
Re: Slow sessions.
312101 by: Rob Adams
312104 by: Rob Adams
312106 by: Bostjan Skufca
312107 by: Bostjan Skufca
312109 by: Rob Adams
312111 by: Bostjan Skufca
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
I'm trying to debug an issue which I think is more to do with Apache
than PHP, but perhaps someone else has experience with this. Using
opensuse 11.4, custom compile of kernel 2.6.38, custom compile of
Apache httpd 2.2.17, and PHP 3.3.6. phpinfo() page works correctly so
my httpd.conf is configured to deal with PHP.
Using a plain .php file which contains a form with only a submit
button, at first the browser loads the .php correctly. Then click
submit in the form, and the browser asks me if I want to open or
download and save locally the .php file I have requested. This is
disturbing since it is potentially a security issue.
1. This only happens with method=POST. method=GET works correctly.
2. Using the same form as an .html file, same failure, so it is not
directly connected to PHP. I have posted an issue with Apache (50978)
but no response yet.
3. Custom kernel and httpd in Opensuse 11.3 worked correctly. I have
posted a question with Opensuse forums but no response.
Is anyone successfully using a custom compile of Apache+PHP with
Opensuse 11.4?
--- End Message ---
--- Begin Message ---
> I'm trying to debug an issue which I think is more to do with Apache than
> PHP, but perhaps someone else has experience with this. Using opensuse
> 11.4, custom compile of kernel 2.6.38, custom compile of Apache httpd
> 2.2.17, and PHP 3.3.6. phpinfo() page works correctly so my httpd.conf is
> configured to deal with PHP.
>
> Using a plain .php file which contains a form with only a submit button,
at first
> the browser loads the .php correctly. Then click submit in the form, and
the
> browser asks me if I want to open or download and save locally the .php
file I
> have requested. This is disturbing since it is potentially a security
issue.
>
> 1. This only happens with method=POST. method=GET works correctly.
> 2. Using the same form as an .html file, same failure, so it is not
directly
> connected to PHP. I have posted an issue with Apache (50978) but no
> response yet.
Can you post a link; if not:
Can you show the contents of the php file being downloaded or at least the
first and last 15 lines?
Not sure why the method would make the diff yet here we are. You could check
the variables_order string in your php.ini file.
And have you tried adding
enctype="multipart/form-data" or
enctype="application/x-www-form-urlencoded" (more suited for GET)
to the FORM tag ie <FORM id="formID" action="some_action.php" method="POST"
enctype="multipart/form-data">
The reason I asked the last part is because you stated that it works fine if
you pass via GET and not when you use POST and because they are both encoded
differently and it could be that the server isn't set correctly to decode
$_POST data and so does the download instead.
More details about how you are collecting the form data and how the data is
then processed would be helpful.
Thank you,
Marc Hall
HallMarc Websites
610.446.3346
http://www.hallmarcwebsites.com/
Spread the word about my services and earn money!
Contact me for details.
--- End Message ---
--- Begin Message ---
HallMarc Websites wrote:
>> I'm trying to debug an issue which I think is more to do with Apache
than
>> PHP, but perhaps someone else has experience with this. Using
opensuse
>> 11.4, custom compile of kernel 2.6.38, custom compile of Apache
httpd
>> 2.2.17, and PHP 3.3.6. phpinfo() page works correctly so my
httpd.conf is
>> configured to deal with PHP.
>>
>> Using a plain .php file which contains a form with only a submit
button,
> at first
>> the browser loads the .php correctly. Then click submit in the form,
and
> the
>> browser asks me if I want to open or download and save locally the
.php
> file I
>> have requested. This is disturbing since it is potentially a
security
> issue.
>>
>> 1. This only happens with method=POST. method=GET works correctly.
>> 2. Using the same form as an .html file, same failure, so it is not
> directly
>> connected to PHP. I have posted an issue with Apache (50978) but no
>> response yet.
>
> Can you post a link; if not:
> Can you show the contents of the php file being downloaded or at
least the
> first and last 15 lines?
> Not sure why the method would make the diff yet here we are. You
could
> check the variables_order string in your php.ini file.
> And have you tried adding
> enctype="multipart/form-data" or
> enctype="application/x-www-form-urlencoded" (more suited for GET)
> to the FORM tag ie <FORM id="formID" action="some_action.php"
> method="POST" enctype="multipart/form-data">
>
> The reason I asked the last part is because you stated that it works
fine
> if you pass via GET and not when you use POST and because they are
both
> encoded differently and it could be that the server isn't set
correctly to
> decode $_POST data and so does the download instead.
>
> More details about how you are collecting the form data and how the
data
> is then processed would be helpful.
>
Thanks for your interest.
Here is my complete test php file:
<?php
echo "crash test<br />";
$cont = "<form action='".$_SERVER['PHP_SELF']."' method='POST'>
<input type='submit' name='button' value='submit' />
</form>";
echo $cont;
echo "ended<br />";
?>
Running this file produces the form correctly at first. Then click
submit and the response of the server is to send the next page as text.
In the background a child process dies. I guess this severs the link to
the php handler. If httpd is run with -X to generate a single process,
this process dies and the server stops, with no effort to serve up a
file of any kind.
If I take the above file and convert to regular html, same behaviour.
This is why I say it has little to do with PHP. However if used in
connection with php it can result in some nasty security implications.
I did try adding enctype, but this did not help. I think this is
because the process is killed very early in dealing with the post
method and never gets to formulating something to send back.
I did get a backtrace from gdb, and this is posted on the
issues.apache.org website.
--- End Message ---
--- Begin Message ---
> Thanks for your interest.
> Here is my complete test php file:
>
> <?php
> echo "crash test<br />";
> $cont = "<form action='".$_SERVER['PHP_SELF']."' method='POST'> <input
> type='submit' name='button' value='submit' /> </form>"; echo $cont; echo
> "ended<br />"; ?>
>
> Running this file produces the form correctly at first. Then click submit
and
> the response of the server is to send the next page as text.
>
> In the background a child process dies. I guess this severs the link to
the php
> handler. If httpd is run with -X to generate a single process, this
process dies
> and the server stops, with no effort to serve up a file of any kind.
>
> If I take the above file and convert to regular html, same behaviour.
> This is why I say it has little to do with PHP. However if used in
connection
> with php it can result in some nasty security implications.
>
> I did try adding enctype, but this did not help. I think this is because
the
> process is killed very early in dealing with the post method and never
gets to
> formulating something to send back.
>
> I did get a backtrace from gdb, and this is posted on the
issues.apache.org
> website.
>
Well, I can't say I have time to search issues.apache.org for this and I
have to drop out of this thread as a huge project just appeared on my desk.
--- End Message ---
--- Begin Message ---
On 3/25/2011 3:55 PM, Peter Lind wrote:
More info (including some code) would be needed to get to the bottom
of this, I'd say. Hard to diagnose what's happening otherwise.
Regards
Peter
So I guess there is no list of things to check for sessions? I'll try
to pair down the code to something postable, but it does work on the old
server.....let me see what I can come up with.
--
Mark B
--- End Message ---
--- Begin Message ---
call session_destroy(); then start the session again
--- End Message ---
--- Begin Message ---
i got it but i didn't understand what to do exactly
uploading a file in a folder is easy for me
than what i must do in db?
--- End Message ---
--- Begin Message ---
storing what in db?
my codes was abt to store the file when uploading what is the difference
can i give me in an example?
--- End Message ---
--- Begin Message ---
On Mon, 2011-03-28 at 18:18 +0430, Negin Nickparsa wrote:
> storing what in db?
> my codes was abt to store the file when uploading what is the difference
> can i give me in an example?
When you copy the file use code like:
move_uploaded_file($_FILES['image']['tmp_name'],
$_FILES['image']['tmp_name']);
adding in any path information you need. I've assumed your input element
is called 'image' here.
Then make a query call, with various fields you will need at a later
date:
$sql = "INSERT INTO files (original_name, temp_name, etc) VALUES
('{$_FILES['image']['name']}', '{$_FILES['image']['tmp_name']}', etc)";
$result = mysql_query($sql);
You'll need to refine the code a bit, but the basics are here. You can
then use queries later to retrieve what files are available to what user
based on the other fields you filled in with this query.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
I had allways used PHP as an Apache module up intil now. They seem
incompatible.
I reinstalled PHP as a CGI binary. PHP inserts the following:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
ScriptAlias /php/ "C:/Program Files/PHP536/"
Action application/x-httpd-php "C:/Program Files/PHP536/php-cgi.exe"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
Apache will start now but when I try to run any PHP scripts, Apache trys to
add "/Program Files" to the physical path; I get the page not found error
and the following in the log file:
"File does not exist: C:/WEBSITE/docs/Program Files"
What is wrong??
"Tommy Pham" <[email protected]> wrote in message
news:[email protected]...
On Fri, Mar 25, 2011 at 1:44 PM, Pierre Joye <[email protected]> wrote:
> On Fri, Mar 25, 2011 at 8:12 PM, Tommy Pham <[email protected]> wrote:
>
>> There used to be a VC6 binary release for PHP v5.3.3 at
>> windows.php.net but I don't see a VC6 build for v5.3 now. Any way,
>> since you're using using Windows, why not just run it as FastCGI? It
>> runs fine on Win2003 (x86), Win7 x64, Win08 (x86 & x64), and Win08r2.
>
> Apache module works just fine and is in many situations much faster than
> fcgi.
I've never tested the difference for performance. If that's the case,
any particular reason to stop support ISAPI for IIS then? or is
FastCGI faster than ISAPI for IIS? Prior to upgrading to PHP v5.3 and
Windows 64bit, I had faster initial response time from ISAPI. Now
with FastCGI, the initial response takes longer. As for performance
difference through repeated requests, I don't notice the difference
between ISAPI v5.2 and FastCGI v5.3.
>
>> Are using a specific Apache module that's why you need to use httpd?
>> If so, you could use the (non official) Apache Lounge's binary.
>
> There are no official builds of Apache, but convenience builds.
>
> Cheers,
> --
> Pierre
>
> @pierrejoye | http://blog.thepimp.net | http://www.libgd.org
>
I've meant official in the sense that one could download from the
official/mirror site. Thus it's more trust worthy, in terms of non
malicious code.
--- End Message ---
--- Begin Message ---
I would still like to offer in my CMS to be able to choose in which
browser I want to display the current page. Is this possible or I in
program can open only default browser? Can I at least choose wheter to
open a new tab or a new window?
Thanks in advance,
-- When the sun rises I receive and when it sets I forgive ->
http://moj.skavt.net/gleskovs/
Always in Heart, Grega Leskovšek
2011/3/27 Richard Quadling <[email protected]>:
> On 26 March 2011 10:22, Ashley Sheridan <[email protected]> wrote:
>> On Fri, 2011-03-25 at 18:05 -0700, Tommy Pham wrote:
>>
>>> On Fri, Mar 25, 2011 at 2:59 PM, Grega Leskovšek <[email protected]> wrote:
>>> > I am working on CMS designed to those who are unfamiliar with a
>>> > computer world and I want to offer a task where on a push of a button
>>> > it will save current working page in textarea/s and open this page in
>>> > a new tab or in a new window.
>>>
>>> PHP is server side. "push of a button" is client side. Google
>>> javascript+onClick.
>>>
>>> > I googled some, but am still not sure how can I do it.
>>> >
>>> > Do I have to use target="_new" - I can not do this - I am working this
>>> > for my University seminar and it has to be valid HTML5.
>>> >
>>> > Please help me improve my plan
>>> > 1. I check wheter the user is using windows, linux, mac and then show
>>> > appropriate possibility of all browsers for the targeted platform
>>> > (WIN:IE,SA,FF,CH,OP, LINUX:FF.CHROMIUM and I need help for the mac
>>> > also besides SA and FF what does it have among browsers?)
>>>
>>> Have you tried to google for browser versions and platform? While
>>> searching for the same thing long time ago, I found a site that lists
>>> them. Also, note that since you'll be using onClick for "push of a
>>> button", beware of Javascript version difference among the browsers.
>>> IIRC, IE is supports 1.3 and FF supports 1.9. Haven't tested the
>>> others so couldn't tell you.
>>>
>>> > 2. When the browser clicks button with the image of browsers inside
>>> > anchor I target _new and location of the current file
>>> >
>>> > ?1 How can I offer option to open a new window not a new tab?
>>> > ?2 How can I avoid the target attribute?
>>> > ?3 How can I make a click on an image to produce action - or what do
>>> > You suggest me to use - I would prefer img element not button with an
>>> > image - how can I do this?
>>> >
>>> > Once I will finish it I will offer here software to everybody so I
>>> > will be able to get some response and improve it and this is one of
>>> > the major problems otherwise it is already functional.
>>> >
>>> > Please help me, thanks in advance - or ? You think I could do this better
>>> > in JS?
>>> > -- When the sun rises I receive and when it sets I forgive ->
>>> > http://moj.skavt.net/gleskovs/
>>> > Always in Heart, Grega Leskovšek
>>> >
>>>
>>> I don't know if you have Flash in your tool belt but have you
>>> considering using it? It may simply your life with various browsers
>>> and their versions across different platforms. Note: Flash does tend
>>> to be sluggish in terms of loading time and how much of what you need
>>> the Flash to do.
>>>
>>> Regards,
>>> Tommy
>>>
>>
>>
>> I'd avoid trying to guess the browser entirely. There are always loads
>> of fringe browsers that are in use, and things like Wine that allows
>> people to run IE on Linux, as well as other Windows-based browsers too.
>> As soon as you're trying to write a script that detects a specific
>> browser and does something then you're already doing it wrong. Don't
>> test for the browser, test for the feature that you're using. Javascript
>> has a useful function called hasFeature which may help here.
>>
>> The main reason why it's bad to try and detect a browser and act on it
>> is because you can get many browsers that work across a wide variety of
>> operating systems such as Fx & Opera, which vary from version to version
>> and OS to OS.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>
> A common approach to web dev is to start with a dumb page - just HTML
> and then add CSS and JS. This is known as progressive enhancement.
>
> Another approach which I've read about recently is called regressive
> enhancement. Essentially, you start at the cutting edge, using the
> functionality that you want (canvas for example), and then add in the
> missing features.
>
> As more of the browsers that support the newer features become the
> popular ones, you end up with less code providing support for older
> browsers. So, when every browser supports canvas, you don't need to
> install any code to emulate the canvas. Modenizr and YepNope are the
> tools I read about for this.
>
> --
> Richard Quadling
> Twitter : EE : Zend
> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
>
--- End Message ---
--- Begin Message ---
On Mon, 2011-03-28 at 17:44 +0200, Grega Leskovšek wrote:
> I would still like to offer in my CMS to be able to choose in which
> browser I want to display the current page. Is this possible or I in
> program can open only default browser? Can I at least choose wheter to
> open a new tab or a new window?
> Thanks in advance,
> -- When the sun rises I receive and when it sets I forgive ->
> http://moj.skavt.net/gleskovs/
> Always in Heart, Grega Leskovšek
>
>
>
>
> 2011/3/27 Richard Quadling <[email protected]>:
> > On 26 March 2011 10:22, Ashley Sheridan <[email protected]> wrote:
> >> On Fri, 2011-03-25 at 18:05 -0700, Tommy Pham wrote:
> >>
> >>> On Fri, Mar 25, 2011 at 2:59 PM, Grega Leskovšek <[email protected]>
> >>> wrote:
> >>> > I am working on CMS designed to those who are unfamiliar with a
> >>> > computer world and I want to offer a task where on a push of a button
> >>> > it will save current working page in textarea/s and open this page in
> >>> > a new tab or in a new window.
> >>>
> >>> PHP is server side. "push of a button" is client side. Google
> >>> javascript+onClick.
> >>>
> >>> > I googled some, but am still not sure how can I do it.
> >>> >
> >>> > Do I have to use target="_new" - I can not do this - I am working this
> >>> > for my University seminar and it has to be valid HTML5.
> >>> >
> >>> > Please help me improve my plan
> >>> > 1. I check wheter the user is using windows, linux, mac and then show
> >>> > appropriate possibility of all browsers for the targeted platform
> >>> > (WIN:IE,SA,FF,CH,OP, LINUX:FF.CHROMIUM and I need help for the mac
> >>> > also besides SA and FF what does it have among browsers?)
> >>>
> >>> Have you tried to google for browser versions and platform? While
> >>> searching for the same thing long time ago, I found a site that lists
> >>> them. Also, note that since you'll be using onClick for "push of a
> >>> button", beware of Javascript version difference among the browsers.
> >>> IIRC, IE is supports 1.3 and FF supports 1.9. Haven't tested the
> >>> others so couldn't tell you.
> >>>
> >>> > 2. When the browser clicks button with the image of browsers inside
> >>> > anchor I target _new and location of the current file
> >>> >
> >>> > ?1 How can I offer option to open a new window not a new tab?
> >>> > ?2 How can I avoid the target attribute?
> >>> > ?3 How can I make a click on an image to produce action - or what do
> >>> > You suggest me to use - I would prefer img element not button with an
> >>> > image - how can I do this?
> >>> >
> >>> > Once I will finish it I will offer here software to everybody so I
> >>> > will be able to get some response and improve it and this is one of
> >>> > the major problems otherwise it is already functional.
> >>> >
> >>> > Please help me, thanks in advance - or ? You think I could do this
> >>> > better in JS?
> >>> > -- When the sun rises I receive and when it sets I forgive ->
> >>> > http://moj.skavt.net/gleskovs/
> >>> > Always in Heart, Grega Leskovšek
> >>> >
> >>>
> >>> I don't know if you have Flash in your tool belt but have you
> >>> considering using it? It may simply your life with various browsers
> >>> and their versions across different platforms. Note: Flash does tend
> >>> to be sluggish in terms of loading time and how much of what you need
> >>> the Flash to do.
> >>>
> >>> Regards,
> >>> Tommy
> >>>
> >>
> >>
> >> I'd avoid trying to guess the browser entirely. There are always loads
> >> of fringe browsers that are in use, and things like Wine that allows
> >> people to run IE on Linux, as well as other Windows-based browsers too.
> >> As soon as you're trying to write a script that detects a specific
> >> browser and does something then you're already doing it wrong. Don't
> >> test for the browser, test for the feature that you're using. Javascript
> >> has a useful function called hasFeature which may help here.
> >>
> >> The main reason why it's bad to try and detect a browser and act on it
> >> is because you can get many browsers that work across a wide variety of
> >> operating systems such as Fx & Opera, which vary from version to version
> >> and OS to OS.
> >>
> >> Thanks,
> >> Ash
> >> http://www.ashleysheridan.co.uk
> >>
> >>
> >>
> >
> > A common approach to web dev is to start with a dumb page - just HTML
> > and then add CSS and JS. This is known as progressive enhancement.
> >
> > Another approach which I've read about recently is called regressive
> > enhancement. Essentially, you start at the cutting edge, using the
> > functionality that you want (canvas for example), and then add in the
> > missing features.
> >
> > As more of the browsers that support the newer features become the
> > popular ones, you end up with less code providing support for older
> > browsers. So, when every browser supports canvas, you don't need to
> > install any code to emulate the canvas. Modenizr and YepNope are the
> > tools I read about for this.
> >
> > --
> > Richard Quadling
> > Twitter : EE : Zend
> > @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
> >
Firstly, this isn't something that can be done in PHP, as PHP is a
server-side language, so things like opening new tabs/windows isn't
possible.
You can open new windows with Javascript, but you can't determine what
browser they open in, or if indeed that a given browser is even
installed on that computer.
On to your last question. I believe some browsers do have an api to open
a link in a new tab or window specifically, but they differ from browser
to browser. One way of ensuring a link opens in a new window and not a
tab is to open the window with Javascript and resize it, which should
force that browser to not open it in a tab.
However, if you're trying to offer this from your CMS, then maybe you
should really think about limiting the control your users have if you
really think they are going to break the layout in some browsers.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Hi,
I'd like to bat around some pros / cons of selecting xinetd to implement a
socket server. From my perspective the list is something like this:
xinetd pros
. no need to rewrite forking functionality, 'server' can be written as
simple php script
. forking potentially faster than php-based implementation
xinetd cons
. time tradeoff learning xinetd configuration vs coding in support directly
in php implementation
. potentially less maintainable depending on staff, likely php dev team
more capable of maintaining 100% php solution
Interested in your thoughts!
-nathan
--- End Message ---
--- Begin Message ---
Xinetd will definitely be faster way than coding your daemon in PHP.
You have to consider many other things as well:
- do your worker processes run under various UIDs (do they do
setuid/setgid)?
- do your workers die after processing each request/client or do they
process multiple connections?
- do you need inter-worker communication?
- resource locking issues, etc?
What is your goal, the function of your daemon/socket server?
You can find PHP socket server implementations around the net already:
- Nanoserv being one: http://nanoserv.si.kz/
- something of "mine": https://github.com/bostjan/PHP-application-server
Of course, it is always a good excercise to write your own. But that is not
for faint hearted :)
b.
On 28 March 2011 18:25, Nathan Nobbe <[email protected]> wrote:
> Hi,
>
> I'd like to bat around some pros / cons of selecting xinetd to implement a
> socket server. From my perspective the list is something like this:
>
> xinetd pros
> . no need to rewrite forking functionality, 'server' can be written as
> simple php script
> . forking potentially faster than php-based implementation
>
> xinetd cons
> . time tradeoff learning xinetd configuration vs coding in support
> directly
> in php implementation
> . potentially less maintainable depending on staff, likely php dev team
> more capable of maintaining 100% php solution
>
> Interested in your thoughts!
>
> -nathan
>
--- End Message ---
--- Begin Message ---
On Mon, Mar 28, 2011 at 12:38 PM, Bostjan Skufca <[email protected]> wrote:
> Xinetd will definitely be faster way than coding your daemon in PHP.
>
In this case:
> You have to consider many other things as well:
> - do your worker processes run under various UIDs (do they do
> setuid/setgid)?
>
no
> - do your workers die after processing each request/client or do they
> process multiple connections?
>
die after each request
> - do you need inter-worker communication?
>
no
> - resource locking issues, etc?
>
perhaps some, but i think this could be handled via a select to the database
prior to a write
> What is your goal, the function of your daemon/socket server?
>
basically to process an incoming payload from a client, parse and store the
results. not sure why the requirements are to accept the payload over
non-http, but that is out of my control.
i guess you can see where im going with this, basically, why reinvent the
wheel w/ the daemon code when xinetd is available. i suppose those php
libraries you mentioned are an argument against that, but then there is the
speed benefit of xinetd. i guess it just comes down to a battle of
tradeoffs.
-nathan
--- End Message ---
--- Begin Message ---
If you need high performance you probably already know that it will be very
expensive CPU wise if workers are spawned on each request. If you don't, I
would not bother with daemon and just use xinetd. You can always add
daemon-handling stuff later on.
Well I do hope you find a good working solution with as little inconvenience
as possible,
b.
On 28 March 2011 21:27, Nathan Nobbe <[email protected]> wrote:
> On Mon, Mar 28, 2011 at 12:38 PM, Bostjan Skufca <[email protected]> wrote:
>
>> Xinetd will definitely be faster way than coding your daemon in PHP.
>>
>
> In this case:
>
>> You have to consider many other things as well:
>> - do your worker processes run under various UIDs (do they do
>> setuid/setgid)?
>>
> no
>
>
>> - do your workers die after processing each request/client or do they
>> process multiple connections?
>>
> die after each request
>
>
>> - do you need inter-worker communication?
>>
> no
>
>
>> - resource locking issues, etc?
>>
> perhaps some, but i think this could be handled via a select to the
> database prior to a write
>
>
>> What is your goal, the function of your daemon/socket server?
>>
> basically to process an incoming payload from a client, parse and store the
> results. not sure why the requirements are to accept the payload over
> non-http, but that is out of my control.
>
> i guess you can see where im going with this, basically, why reinvent the
> wheel w/ the daemon code when xinetd is available. i suppose those php
> libraries you mentioned are an argument against that, but then there is the
> speed benefit of xinetd. i guess it just comes down to a battle of
> tradeoffs.
>
> -nathan
>
--- End Message ---
--- Begin Message ---
On Mon, Mar 28, 2011 at 3:34 PM, Bostjan Skufca <[email protected]> wrote:
> If you need high performance you probably already know that it will be very
> expensive CPU wise if workers are spawned on each request. If you don't, I
> would not bother with daemon and just use xinetd. You can always add
> daemon-handling stuff later on.
>
> Well I do hope you find a good working solution with as little
> inconvenience as possible,
> b.
hmm, wouldn't both the solutions most likely be forking? php daemon would
fork since threading isn't supported, and xinetd, probly best to have it
fork for the same reason apache is typically configured to fork. right?
-nathan
--- End Message ---
--- Begin Message ---
Nathan Nobbe wrote:
> On Mon, Mar 28, 2011 at 3:34 PM,
Bostjan Skufca <[email protected]> wrote:
>
>> If
you need high performance you probably already know that it will be
>> very
>> expensive CPU wise if workers are spawned on
each request. If you don't,
>> I
>> would not bother
with daemon and just use xinetd. You can always add
>>
daemon-handling stuff later on.
>>
>> Well I do hope
you find a good working solution with as little
>>
inconvenience as possible,
>> b.
>
>
> hmm, wouldn't both the solutions most likely be forking? php
daemon would
> fork since threading isn't supported, and xinetd,
probly best to have it
> fork for the same reason apache is
typically configured to fork. right?
Speak for yourself.
I've always configured my systems to thread. Since IBM rewrote the
threading library several years back (NPTL), Theading works. I use
the threading version of apache and threading is enabled in PHP.
It works pretty well until its under attack by the spammers.
--Curtis
--- End Message ---
--- Begin Message ---
At 01:32 AM 3/28/2011, Hans Ã
hlin wrote:
Do you have SELinux installed?
2011/3/28 Ethan Rosenberg <[email protected]>:
> Dear List -
>
> Thanks for all your help in the past. Â Here is another one...
>
> I am getting a Permission Denied" message
when I try to run a PHP script. Â I
> just changed the mode on the directory and the files to 777. Â This problem
> arose when I changed the permissions. Â I thought I was solving a problem,
> because I could not open a file for writing. Â I was not receiving error
> messages, but no file was created.
>
> Help and advice, please.
>
> Ethan Rosenberg
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
**********************************************
 Hans Ã
hlin
  Tel: +46761488019
  icq: 275232967
  http://www.kronan-net.com/
  irc://irc.freenode.net:6667 - TheCoin
**********************************************
Hans -
Sorry, I did not include my signature, which
includes all the requested information.
Here it is....
Ethan
==========
MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On 3/26/2011 11:07 AM, Bostjan Skufca wrote:
Can you strace it's execution and see where your delay is comming from? If
you are using apache, make it create just one child and strace that one when
you generate a request.
Thanks for the advice. I installed strace on the new server, and it has
a thirty second delay on the flock call (opening the session file):
open("/path/to/session/sess_SESSIONID", O_RDWR|O_CREAT, 0600) = 20
flock(20, LOCK_EX) = -1 ENOLCK (No locks available)
fcntl64(20, F_SETFD, FD_CLOEXEC) = 0
fstat64(20, {st_mode=S_IFREG|0644, st_size=13, ...}) = 0
pread64(20, "cpixUser|b:1;", 13, 0) = 13
gettimeofday({1301331125, 622954}, NULL) = 0
gettimeofday({1301331125, 623046}, NULL) = 0
brk(0x989d000) = 0x989d000
gettimeofday({1301331125, 623301}, NULL) = 0
pwrite64(20, "cpixUser|b:1;", 13, 0) = 13
close(20) = 0
This has the correct session file name (ie
"/path/to/session/sess_SESSIONID").
So then I installed strace on one of the older servers, to see what it
was doing, and this is what I see where it is opening the session file:
open("\"M\235\240GU\21", O_RDWR|O_CREAT, 0600) = 9
flock(9, LOCK_EX) = -1 EOPNOTSUPP (Operation not
supported)
fcntl(9, F_SETFD, FD_CLOEXEC) = 0
fstat(9, {st_mode=S_IFCHR|040, st_rdev=makedev(113, 1114152), ...}) = 0
lseek(9, 0, SEEK_SET) = 0
read(9, "cpixUser|b:1;"..., 13) = 13
gettimeofday({540876916, 1078020164}, {3221773391, 671636288}) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
lseek(9, 0, SEEK_SET) = 0
write(9, "cpixUser|b:1;"..., 13) = 13
close(9) = 0
I don't know why it has the session file as this: "\"M\235\240GU\21".
So it looks like the flock(?) is taking 30 seconds to timeout on the new
server, and failing instantly on the old ones. On the new server, I
have a message in /var/log/messages that reads:
Mar 28 10:38:34 webServer kernel: lockd: server mainFileServer not
responding, timed out
I get this message evertime I call session_start(). I have tried
reloading the new server from scratch (CentOS 5.5, php 5.2.17, apache
2.2) and it is still doing the same thing.
--- End Message ---
--- Begin Message ---
Bostjan,
Thanks again for the tip. At this point, it looks like there is an
issue with my main file server. It's weird that the older servers were
working with it fine though (by instantly failing on lock), so I
originally thought it might be a php issue. I think I'm making progress
on it now though.
-- Rob
On 3/28/2011 12:08 PM, Rob Adams wrote:
On 3/26/2011 11:07 AM, Bostjan Skufca wrote:
Can you strace it's execution and see where your delay is comming
from? If
you are using apache, make it create just one child and strace that
one when
you generate a request.
Thanks for the advice. I installed strace on the new server, and it has
a thirty second delay on the flock call (opening the session file):
open("/path/to/session/sess_SESSIONID", O_RDWR|O_CREAT, 0600) = 20
flock(20, LOCK_EX) = -1 ENOLCK (No locks available)
fcntl64(20, F_SETFD, FD_CLOEXEC) = 0
fstat64(20, {st_mode=S_IFREG|0644, st_size=13, ...}) = 0
pread64(20, "cpixUser|b:1;", 13, 0) = 13
gettimeofday({1301331125, 622954}, NULL) = 0
gettimeofday({1301331125, 623046}, NULL) = 0
brk(0x989d000) = 0x989d000
gettimeofday({1301331125, 623301}, NULL) = 0
pwrite64(20, "cpixUser|b:1;", 13, 0) = 13
close(20) = 0
This has the correct session file name (ie
"/path/to/session/sess_SESSIONID").
So then I installed strace on one of the older servers, to see what it
was doing, and this is what I see where it is opening the session file:
open("\"M\235\240GU\21", O_RDWR|O_CREAT, 0600) = 9
flock(9, LOCK_EX) = -1 EOPNOTSUPP (Operation not supported)
fcntl(9, F_SETFD, FD_CLOEXEC) = 0
fstat(9, {st_mode=S_IFCHR|040, st_rdev=makedev(113, 1114152), ...}) = 0
lseek(9, 0, SEEK_SET) = 0
read(9, "cpixUser|b:1;"..., 13) = 13
gettimeofday({540876916, 1078020164}, {3221773391, 671636288}) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
lseek(9, 0, SEEK_SET) = 0
write(9, "cpixUser|b:1;"..., 13) = 13
close(9) = 0
I don't know why it has the session file as this: "\"M\235\240GU\21".
So it looks like the flock(?) is taking 30 seconds to timeout on the new
server, and failing instantly on the old ones. On the new server, I have
a message in /var/log/messages that reads:
Mar 28 10:38:34 webServer kernel: lockd: server mainFileServer not
responding, timed out
I get this message evertime I call session_start(). I have tried
reloading the new server from scratch (CentOS 5.5, php 5.2.17, apache
2.2) and it is still doing the same thing.
--- End Message ---
--- Begin Message ---
Great, please report back if/when you discover the cause.
Meanwhile doing "man 2 flock" yields info about ENOLCK: "The kernel ran out
of memory for allocating lock records." This concerns your new server. The
old one does not support locking, or so it seems (EOPNOTSUPP).
b.
On 28 March 2011 23:15, Rob Adams <[email protected]> wrote:
> Bostjan,
>
> Thanks again for the tip. At this point, it looks like there is an issue
> with my main file server. It's weird that the older servers were working
> with it fine though (by instantly failing on lock), so I originally thought
> it might be a php issue. I think I'm making progress on it now though.
>
> -- Rob
>
>
>
> On 3/28/2011 12:08 PM, Rob Adams wrote:
>
>> On 3/26/2011 11:07 AM, Bostjan Skufca wrote:
>>
>>> Can you strace it's execution and see where your delay is comming
>>> from? If
>>> you are using apache, make it create just one child and strace that
>>> one when
>>> you generate a request.
>>>
>>
>> Thanks for the advice. I installed strace on the new server, and it has
>> a thirty second delay on the flock call (opening the session file):
>>
>> open("/path/to/session/sess_SESSIONID", O_RDWR|O_CREAT, 0600) = 20
>> flock(20, LOCK_EX) = -1 ENOLCK (No locks available)
>> fcntl64(20, F_SETFD, FD_CLOEXEC) = 0
>> fstat64(20, {st_mode=S_IFREG|0644, st_size=13, ...}) = 0
>> pread64(20, "cpixUser|b:1;", 13, 0) = 13
>> gettimeofday({1301331125, 622954}, NULL) = 0
>> gettimeofday({1301331125, 623046}, NULL) = 0
>> brk(0x989d000) = 0x989d000
>> gettimeofday({1301331125, 623301}, NULL) = 0
>> pwrite64(20, "cpixUser|b:1;", 13, 0) = 13
>> close(20) = 0
>>
>> This has the correct session file name (ie
>> "/path/to/session/sess_SESSIONID").
>>
>> So then I installed strace on one of the older servers, to see what it
>> was doing, and this is what I see where it is opening the session file:
>>
>> open("\"M\235\240GU\21", O_RDWR|O_CREAT, 0600) = 9
>> flock(9, LOCK_EX) = -1 EOPNOTSUPP (Operation not supported)
>> fcntl(9, F_SETFD, FD_CLOEXEC) = 0
>> fstat(9, {st_mode=S_IFCHR|040, st_rdev=makedev(113, 1114152), ...}) = 0
>> lseek(9, 0, SEEK_SET) = 0
>> read(9, "cpixUser|b:1;"..., 13) = 13
>> gettimeofday({540876916, 1078020164}, {3221773391, 671636288}) = 0
>> sigprocmask(SIG_BLOCK, NULL, []) = 0
>> lseek(9, 0, SEEK_SET) = 0
>> write(9, "cpixUser|b:1;"..., 13) = 13
>> close(9) = 0
>>
>> I don't know why it has the session file as this: "\"M\235\240GU\21".
>>
>> So it looks like the flock(?) is taking 30 seconds to timeout on the new
>> server, and failing instantly on the old ones. On the new server, I have
>> a message in /var/log/messages that reads:
>>
>> Mar 28 10:38:34 webServer kernel: lockd: server mainFileServer not
>> responding, timed out
>>
>> I get this message evertime I call session_start(). I have tried
>> reloading the new server from scratch (CentOS 5.5, php 5.2.17, apache
>> 2.2) and it is still doing the same thing.
>>
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
When you say you "installed php 5.3.x and then reverted to 5.2", did you
reinstall/upgrade OS and/or kernel too?
b.
On 28 March 2011 23:40, Bostjan Skufca <[email protected]> wrote:
> Great, please report back if/when you discover the cause.
>
> Meanwhile doing "man 2 flock" yields info about ENOLCK: "The kernel ran out
> of memory for allocating lock records." This concerns your new server. The
> old one does not support locking, or so it seems (EOPNOTSUPP).
>
> b.
>
>
>
> On 28 March 2011 23:15, Rob Adams <[email protected]> wrote:
>
>> Bostjan,
>>
>> Thanks again for the tip. At this point, it looks like there is an issue
>> with my main file server. It's weird that the older servers were working
>> with it fine though (by instantly failing on lock), so I originally thought
>> it might be a php issue. I think I'm making progress on it now though.
>>
>> -- Rob
>>
>>
>>
>> On 3/28/2011 12:08 PM, Rob Adams wrote:
>>
>>> On 3/26/2011 11:07 AM, Bostjan Skufca wrote:
>>>
>>>> Can you strace it's execution and see where your delay is comming
>>>> from? If
>>>> you are using apache, make it create just one child and strace that
>>>> one when
>>>> you generate a request.
>>>>
>>>
>>> Thanks for the advice. I installed strace on the new server, and it has
>>> a thirty second delay on the flock call (opening the session file):
>>>
>>> open("/path/to/session/sess_SESSIONID", O_RDWR|O_CREAT, 0600) = 20
>>> flock(20, LOCK_EX) = -1 ENOLCK (No locks available)
>>> fcntl64(20, F_SETFD, FD_CLOEXEC) = 0
>>> fstat64(20, {st_mode=S_IFREG|0644, st_size=13, ...}) = 0
>>> pread64(20, "cpixUser|b:1;", 13, 0) = 13
>>> gettimeofday({1301331125, 622954}, NULL) = 0
>>> gettimeofday({1301331125, 623046}, NULL) = 0
>>> brk(0x989d000) = 0x989d000
>>> gettimeofday({1301331125, 623301}, NULL) = 0
>>> pwrite64(20, "cpixUser|b:1;", 13, 0) = 13
>>> close(20) = 0
>>>
>>> This has the correct session file name (ie
>>> "/path/to/session/sess_SESSIONID").
>>>
>>> So then I installed strace on one of the older servers, to see what it
>>> was doing, and this is what I see where it is opening the session file:
>>>
>>> open("\"M\235\240GU\21", O_RDWR|O_CREAT, 0600) = 9
>>> flock(9, LOCK_EX) = -1 EOPNOTSUPP (Operation not supported)
>>> fcntl(9, F_SETFD, FD_CLOEXEC) = 0
>>> fstat(9, {st_mode=S_IFCHR|040, st_rdev=makedev(113, 1114152), ...}) = 0
>>> lseek(9, 0, SEEK_SET) = 0
>>> read(9, "cpixUser|b:1;"..., 13) = 13
>>> gettimeofday({540876916, 1078020164}, {3221773391, 671636288}) = 0
>>> sigprocmask(SIG_BLOCK, NULL, []) = 0
>>> lseek(9, 0, SEEK_SET) = 0
>>> write(9, "cpixUser|b:1;"..., 13) = 13
>>> close(9) = 0
>>>
>>> I don't know why it has the session file as this: "\"M\235\240GU\21".
>>>
>>> So it looks like the flock(?) is taking 30 seconds to timeout on the new
>>> server, and failing instantly on the old ones. On the new server, I have
>>> a message in /var/log/messages that reads:
>>>
>>> Mar 28 10:38:34 webServer kernel: lockd: server mainFileServer not
>>> responding, timed out
>>>
>>> I get this message evertime I call session_start(). I have tried
>>> reloading the new server from scratch (CentOS 5.5, php 5.2.17, apache
>>> 2.2) and it is still doing the same thing.
>>>
>>>
>>>
>>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
--- End Message ---
--- Begin Message ---
From: "Bostjan Skufca" <[email protected]>
>When you say you "installed php 5.3.x and then reverted to 5.2", did you
>reinstall/upgrade OS and/or >kernel too?
Yes. The old servers were running some version of FreeBSD. The new server is
running CentOS 5.5.
-- Rob
--- End Message ---
--- Begin Message ---
Seems like session file locking did not work before :)
b.
On 29 March 2011 01:00, Rob Adams <[email protected]> wrote:
> From: "Bostjan Skufca" <[email protected]>
> >When you say you "installed php 5.3.x and then reverted to 5.2", did you
> reinstall/upgrade OS and/or >kernel too?
>
> Yes. The old servers were running some version of FreeBSD. The new server
> is running CentOS 5.5.
>
>
> -- Rob
>
>
--- End Message ---