php-general Digest 11 May 2012 07:53:24 -0000 Issue 7809

Topics (messages 317837 through 317842):

Re: Performance / AB issue?
        317837 by: Lars Nielsen
        317838 by: Matijn Woudt
        317840 by: Camilo Sperberg
        317841 by: Lars Nielsen
        317842 by: Camilo Sperberg

Re: Best practice question regarding set_include_path()
        317839 by: tamouse mailing lists

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 ---
>
>
> Sent from my iPhone 5 Beta [Confidential use only]
>
> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>
>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk> wrote:
>>> Hi there,
>>>
>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I have a
>>> strange issue.
>>>
>>> I have made a Drupal 7 site with a mysql db.
>>>
>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/ it
>>> works
>>> fine.
>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>> kills
>>> apache.
>>> If I stress-test the site with : ab -c 50 -n 1500
>>> http://sitename/static.html it works fine.
>>>
>>> I have set apache's errorlog to debug. But it writes nothing, either in
>>> the virtualhost or in the server-file.
>>>
>>> Can anyone give a hint about what can be wrong?
>>>
>>>
>>
>> What do you mean with 'kills apache', does it terminate apache or does
>> apache hang (eg. 100% cpu), and respond normal after the stress test
>> is over?
>> And what is the index of your site? A php script, or..? Do you have
>> ModRewrite redirects etc?
>>
>> - Matijn
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> Can you visit the site normally? Try less verbosing in apache, that is
> pretty intensive, but as you can benchmark a static file well (with
> moderate high settings), i assume it is some configuration problem in
> drupal.
>
> Greeting.
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hi,

I can visit the site normaly, but with 2-3 concurrent ab test it fails.
seen from 'ps' and 'htop' it seems that both apache and mysql continues to
run normaly but it doesnt respond.

If i run netstat -an after the test it shows this :
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address  State
tcp        0      0 0.0.0.0:22              0.0.0.0:*        LISTEN
tcp        0      0 127.0.0.1:25            0.0.0.0:*        LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*        LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*        LISTEN
tcp        1      0 x.x.x.x:80        x.x.x.x:39237   CLOSE_WAIT
tcp        1      0 x.x.x.x:80        x.x.x.x:39236    CLOSE_WAIT
tcp        0      0 x.x.x.x:22        x.x.x.x:47383    ESTABLISHED
tcp        0      0 127.0.0.1:80            127.0.0.1:34775        
ESTABLISHED
tcp        1      0 x.x.x.x:80        x.x.x.x:39300    CLOSE_WAIT 
ESTABLISHED
tcp        0      0 127.0.0.1:34775         127.0.0.1:80           
ESTABLISHED
tcp        0      0 x.x.x.x:80        x.x.x.x:39330    ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:25                  :::*                    LISTEN

So it does seem like there should be room for new tcp connections?

But if I restart apache then it works again... So I guess it is a
apache/php configuration issue?

-- 
Med venlig hilsen / Best Regards

LFWeb
Lars Nielsen
Thorsensvej 30
4800 Nykøbing Falster
Tlf: +45 20 64 85 76
email : l...@lfweb.dk
www : http://www.lfweb.dk


--- End Message ---
--- Begin Message ---
On Thu, May 10, 2012 at 11:26 PM, Lars Nielsen <l...@lfweb.dk> wrote:
>
>>
>>
>> Sent from my iPhone 5 Beta [Confidential use only]
>>
>> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>>
>>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk> wrote:
>>>> Hi there,
>>>>
>>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I have a
>>>> strange issue.
>>>>
>>>> I have made a Drupal 7 site with a mysql db.
>>>>
>>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/ it
>>>> works
>>>> fine.
>>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>>> kills
>>>> apache.
>>>> If I stress-test the site with : ab -c 50 -n 1500
>>>> http://sitename/static.html it works fine.
>>>>
>>>> I have set apache's errorlog to debug. But it writes nothing, either in
>>>> the virtualhost or in the server-file.
>>>>
>>>> Can anyone give a hint about what can be wrong?
>>>>
>>>>
>>>
>>> What do you mean with 'kills apache', does it terminate apache or does
>>> apache hang (eg. 100% cpu), and respond normal after the stress test
>>> is over?
>>> And what is the index of your site? A php script, or..? Do you have
>>> ModRewrite redirects etc?
>>>
>>> - Matijn
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>
>> Can you visit the site normally? Try less verbosing in apache, that is
>> pretty intensive, but as you can benchmark a static file well (with
>> moderate high settings), i assume it is some configuration problem in
>> drupal.
>>
>> Greeting.
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Hi,
>
> I can visit the site normaly, but with 2-3 concurrent ab test it fails.
> seen from 'ps' and 'htop' it seems that both apache and mysql continues to
> run normaly but it doesnt respond.
>

That sounds like a deadlock or something.. It's also possible it is
waiting for MySQL to respond and some deadlock might happen there

> If i run netstat -an after the test it shows this :
> Active Internet connections (servers and established)
> Proto Recv-Q Send-Q Local Address           Foreign Address  State
> tcp        0      0 0.0.0.0:22              0.0.0.0:*        LISTEN
> tcp        0      0 127.0.0.1:25            0.0.0.0:*        LISTEN
> tcp        0      0 127.0.0.1:3306          0.0.0.0:*        LISTEN
> tcp        0      0 0.0.0.0:80              0.0.0.0:*        LISTEN
> tcp        1      0 x.x.x.x:80        x.x.x.x:39237   CLOSE_WAIT
> tcp        1      0 x.x.x.x:80        x.x.x.x:39236    CLOSE_WAIT
> tcp        0      0 x.x.x.x:22        x.x.x.x:47383    ESTABLISHED
> tcp        0      0 127.0.0.1:80            127.0.0.1:34775
> ESTABLISHED
> tcp        1      0 x.x.x.x:80        x.x.x.x:39300    CLOSE_WAIT
> ESTABLISHED
> tcp        0      0 127.0.0.1:34775         127.0.0.1:80
> ESTABLISHED
> tcp        0      0 x.x.x.x:80        x.x.x.x:39330    ESTABLISHED
> tcp6       0      0 :::22                   :::*                    LISTEN
> tcp6       0      0 ::1:25                  :::*                    LISTEN
>
> So it does seem like there should be room for new tcp connections?

even 10.000 connections at the same time should be fine

>
> But if I restart apache then it works again... So I guess it is a
> apache/php configuration issue?
>

Did you try to run ab from the same server (with http://localhost/) too?
Also, are you running any optimization stuff, like memcached?

- Matijn

--- End Message ---
--- Begin Message ---
On 10 mei 2012, at 23:26, Lars Nielsen wrote:

> 
>> 
>> 
>> Sent from my iPhone 5 Beta [Confidential use only]
>> 
>> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>> 
>>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk> wrote:
>>>> Hi there,
>>>> 
>>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I have a
>>>> strange issue.
>>>> 
>>>> I have made a Drupal 7 site with a mysql db.
>>>> 
>>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/ it
>>>> works
>>>> fine.
>>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>>> kills
>>>> apache.
>>>> If I stress-test the site with : ab -c 50 -n 1500
>>>> http://sitename/static.html it works fine.
>>>> 
>>>> I have set apache's errorlog to debug. But it writes nothing, either in
>>>> the virtualhost or in the server-file.
>>>> 
>>>> Can anyone give a hint about what can be wrong?
>>>> 
>>>> 
>>> 
>>> What do you mean with 'kills apache', does it terminate apache or does
>>> apache hang (eg. 100% cpu), and respond normal after the stress test
>>> is over?
>>> And what is the index of your site? A php script, or..? Do you have
>>> ModRewrite redirects etc?
>>> 
>>> - Matijn
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> 
>> 
>> Can you visit the site normally? Try less verbosing in apache, that is
>> pretty intensive, but as you can benchmark a static file well (with
>> moderate high settings), i assume it is some configuration problem in
>> drupal.
>> 
>> Greeting.
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> 
> Hi,
> 
> I can visit the site normaly, but with 2-3 concurrent ab test it fails.
> seen from 'ps' and 'htop' it seems that both apache and mysql continues to
> run normaly but it doesnt respond.
> 
> If i run netstat -an after the test it shows this :
> Active Internet connections (servers and established)
> Proto Recv-Q Send-Q Local Address           Foreign Address  State
> tcp        0      0 0.0.0.0:22              0.0.0.0:*        LISTEN
> tcp        0      0 127.0.0.1:25            0.0.0.0:*        LISTEN
> tcp        0      0 127.0.0.1:3306          0.0.0.0:*        LISTEN
> tcp        0      0 0.0.0.0:80              0.0.0.0:*        LISTEN
> tcp        1      0 x.x.x.x:80        x.x.x.x:39237   CLOSE_WAIT
> tcp        1      0 x.x.x.x:80        x.x.x.x:39236    CLOSE_WAIT
> tcp        0      0 x.x.x.x:22        x.x.x.x:47383    ESTABLISHED
> tcp        0      0 127.0.0.1:80            127.0.0.1:34775        
> ESTABLISHED
> tcp        1      0 x.x.x.x:80        x.x.x.x:39300    CLOSE_WAIT 
> ESTABLISHED
> tcp        0      0 127.0.0.1:34775         127.0.0.1:80           
> ESTABLISHED
> tcp        0      0 x.x.x.x:80        x.x.x.x:39330    ESTABLISHED
> tcp6       0      0 :::22                   :::*                    LISTEN
> tcp6       0      0 ::1:25                  :::*                    LISTEN
> 
> So it does seem like there should be room for new tcp connections?
> 
> But if I restart apache then it works again... So I guess it is a
> apache/php configuration issue?
> 
> -- 
> Med venlig hilsen / Best Regards
> 
> LFWeb
> Lars Nielsen
> Thorsensvej 30
> 4800 Nykøbing Falster
> Tlf: +45 20 64 85 76
> email : l...@lfweb.dk
> www : http://www.lfweb.dk
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Have you tried benchmarking a really simple php page, such as 

<?php echo 'hello world'; ?>

?

It that works, than it is definitely an issue in Drupal's configuration and not 
in PHP/Apache. Additionally, you could check what happens when you try to 
establish a session or make a database call to rule out those as well, just 
make really simple tests that you know wouldn't fail and run ab on them.

Greetings.


--- End Message ---
--- Begin Message ---
>
> On 10 mei 2012, at 23:26, Lars Nielsen wrote:
>
>>
>>>
>>>
>>> Sent from my iPhone 5 Beta [Confidential use only]
>>>
>>> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>>>
>>>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk> wrote:
>>>>> Hi there,
>>>>>
>>>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I have
>>>>> a
>>>>> strange issue.
>>>>>
>>>>> I have made a Drupal 7 site with a mysql db.
>>>>>
>>>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/ it
>>>>> works
>>>>> fine.
>>>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>>>> kills
>>>>> apache.
>>>>> If I stress-test the site with : ab -c 50 -n 1500
>>>>> http://sitename/static.html it works fine.
>>>>>
>>>>> I have set apache's errorlog to debug. But it writes nothing, either
>>>>> in
>>>>> the virtualhost or in the server-file.
>>>>>
>>>>> Can anyone give a hint about what can be wrong?
>>>>>
>>>>>
>>>>
>>>> What do you mean with 'kills apache', does it terminate apache or does
>>>> apache hang (eg. 100% cpu), and respond normal after the stress test
>>>> is over?
>>>> And what is the index of your site? A php script, or..? Do you have
>>>> ModRewrite redirects etc?
>>>>
>>>> - Matijn
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>
>>> Can you visit the site normally? Try less verbosing in apache, that is
>>> pretty intensive, but as you can benchmark a static file well (with
>>> moderate high settings), i assume it is some configuration problem in
>>> drupal.
>>>
>>> Greeting.
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Hi,
>>
>> I can visit the site normaly, but with 2-3 concurrent ab test it fails.
>> seen from 'ps' and 'htop' it seems that both apache and mysql continues
>> to
>> run normaly but it doesnt respond.
>>
>> If i run netstat -an after the test it shows this :
>> Active Internet connections (servers and established)
>> Proto Recv-Q Send-Q Local Address           Foreign Address  State
>> tcp        0      0 0.0.0.0:22              0.0.0.0:*        LISTEN
>> tcp        0      0 127.0.0.1:25            0.0.0.0:*        LISTEN
>> tcp        0      0 127.0.0.1:3306          0.0.0.0:*        LISTEN
>> tcp        0      0 0.0.0.0:80              0.0.0.0:*        LISTEN
>> tcp        1      0 x.x.x.x:80        x.x.x.x:39237   CLOSE_WAIT
>> tcp        1      0 x.x.x.x:80        x.x.x.x:39236    CLOSE_WAIT
>> tcp        0      0 x.x.x.x:22        x.x.x.x:47383    ESTABLISHED
>> tcp        0      0 127.0.0.1:80            127.0.0.1:34775
>> ESTABLISHED
>> tcp        1      0 x.x.x.x:80        x.x.x.x:39300    CLOSE_WAIT
>> ESTABLISHED
>> tcp        0      0 127.0.0.1:34775         127.0.0.1:80
>> ESTABLISHED
>> tcp        0      0 x.x.x.x:80        x.x.x.x:39330    ESTABLISHED
>> tcp6       0      0 :::22                   :::*
>> LISTEN
>> tcp6       0      0 ::1:25                  :::*
>> LISTEN
>>
>> So it does seem like there should be room for new tcp connections?
>>
>> But if I restart apache then it works again... So I guess it is a
>> apache/php configuration issue?
>>
>> --
>> Med venlig hilsen / Best Regards
>>
>> LFWeb
>> Lars Nielsen
>> Thorsensvej 30
>> 4800 Nykøbing Falster
>> Tlf: +45 20 64 85 76
>> email : l...@lfweb.dk
>> www : http://www.lfweb.dk
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> Have you tried benchmarking a really simple php page, such as
>
> <?php echo 'hello world'; ?>
>
> ?
>
> It that works, than it is definitely an issue in Drupal's configuration
> and not in PHP/Apache. Additionally, you could check what happens when you
> try to establish a session or make a database call to rule out those as
> well, just make really simple tests that you know wouldn't fail and run ab
> on them.
>
> Greetings.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Thanks!

Now I have made
<?php
  echo "Hey from PHP!";
?>

It runs fine from a little concurrency. But with "-c 5 -n 500" it fails
after 308 requests!



Best Regards / Med venlig hilsen

LFWeb
Lars Nielsen


--- End Message ---
--- Begin Message ---

Sent from my iPhone 5 Beta [Confidential use only]

On 11 mei 2012, at 07:09, "Lars Nielsen" <l...@lfweb.dk> wrote:

> 
>> 
>> On 10 mei 2012, at 23:26, Lars Nielsen wrote:
>> 
>>> 
>>>> 
>>>> 
>>>> Sent from my iPhone 5 Beta [Confidential use only]
>>>> 
>>>> On 10 mei 2012, at 17:40, Matijn Woudt <tijn...@gmail.com> wrote:
>>>> 
>>>>> On Thu, May 10, 2012 at 9:04 AM, Lars Nielsen <l...@lfweb.dk> wrote:
>>>>>> Hi there,
>>>>>> 
>>>>>> I have apache-2.22/php 5.3.10 set up on a dedicated server but I have
>>>>>> a
>>>>>> strange issue.
>>>>>> 
>>>>>> I have made a Drupal 7 site with a mysql db.
>>>>>> 
>>>>>> If I stress-test the site with : ab -c 1 -n 150 http://sitename/ it
>>>>>> works
>>>>>> fine.
>>>>>> If I stress-test the site with : ab -c 2 -n 20 http://sitename/ it
>>>>>> kills
>>>>>> apache.
>>>>>> If I stress-test the site with : ab -c 50 -n 1500
>>>>>> http://sitename/static.html it works fine.
>>>>>> 
>>>>>> I have set apache's errorlog to debug. But it writes nothing, either
>>>>>> in
>>>>>> the virtualhost or in the server-file.
>>>>>> 
>>>>>> Can anyone give a hint about what can be wrong?
>>>>>> 
>>>>>> 
>>>>> 
>>>>> What do you mean with 'kills apache', does it terminate apache or does
>>>>> apache hang (eg. 100% cpu), and respond normal after the stress test
>>>>> is over?
>>>>> And what is the index of your site? A php script, or..? Do you have
>>>>> ModRewrite redirects etc?
>>>>> 
>>>>> - Matijn
>>>>> 
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>> 
>>>> 
>>>> Can you visit the site normally? Try less verbosing in apache, that is
>>>> pretty intensive, but as you can benchmark a static file well (with
>>>> moderate high settings), i assume it is some configuration problem in
>>>> drupal.
>>>> 
>>>> Greeting.
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>> 
>>>> 
>>> 
>>> Hi,
>>> 
>>> I can visit the site normaly, but with 2-3 concurrent ab test it fails.
>>> seen from 'ps' and 'htop' it seems that both apache and mysql continues
>>> to
>>> run normaly but it doesnt respond.
>>> 
>>> If i run netstat -an after the test it shows this :
>>> Active Internet connections (servers and established)
>>> Proto Recv-Q Send-Q Local Address           Foreign Address  State
>>> tcp        0      0 0.0.0.0:22              0.0.0.0:*        LISTEN
>>> tcp        0      0 127.0.0.1:25            0.0.0.0:*        LISTEN
>>> tcp        0      0 127.0.0.1:3306          0.0.0.0:*        LISTEN
>>> tcp        0      0 0.0.0.0:80              0.0.0.0:*        LISTEN
>>> tcp        1      0 x.x.x.x:80        x.x.x.x:39237   CLOSE_WAIT
>>> tcp        1      0 x.x.x.x:80        x.x.x.x:39236    CLOSE_WAIT
>>> tcp        0      0 x.x.x.x:22        x.x.x.x:47383    ESTABLISHED
>>> tcp        0      0 127.0.0.1:80            127.0.0.1:34775
>>> ESTABLISHED
>>> tcp        1      0 x.x.x.x:80        x.x.x.x:39300    CLOSE_WAIT
>>> ESTABLISHED
>>> tcp        0      0 127.0.0.1:34775         127.0.0.1:80
>>> ESTABLISHED
>>> tcp        0      0 x.x.x.x:80        x.x.x.x:39330    ESTABLISHED
>>> tcp6       0      0 :::22                   :::*
>>> LISTEN
>>> tcp6       0      0 ::1:25                  :::*
>>> LISTEN
>>> 
>>> So it does seem like there should be room for new tcp connections?
>>> 
>>> But if I restart apache then it works again... So I guess it is a
>>> apache/php configuration issue?
>>> 
>>> --
>>> Med venlig hilsen / Best Regards
>>> 
>>> LFWeb
>>> Lars Nielsen
>>> Thorsensvej 30
>>> 4800 Nykøbing Falster
>>> Tlf: +45 20 64 85 76
>>> email : l...@lfweb.dk
>>> www : http://www.lfweb.dk
>>> 
>>> 
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>> 
>> 
>> Have you tried benchmarking a really simple php page, such as
>> 
>> <?php echo 'hello world'; ?>
>> 
>> ?
>> 
>> It that works, than it is definitely an issue in Drupal's configuration
>> and not in PHP/Apache. Additionally, you could check what happens when you
>> try to establish a session or make a database call to rule out those as
>> well, just make really simple tests that you know wouldn't fail and run ab
>> on them.
>> 
>> Greetings.
>> 
>> 
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> Thanks!
> 
> Now I have made
> <?php
>  echo "Hey from PHP!";
> ?>
> 
> It runs fine from a little concurrency. But with "-c 5 -n 500" it fails
> after 308 requests!
> 
> 
> 
> Best Regards / Med venlig hilsen
> 
> LFWeb
> Lars Nielsen
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Have you tried benchmarking from localhost? Do you have any active firewall? 
Selinux? Shorewall? Anything that could block a ddos attack?

Greetings. 

--- End Message ---
--- Begin Message ---
On Thu, May 10, 2012 at 1:50 PM, admin <ad...@buskirkgraphics.com> wrote:
>
>
> -----Original Message-----
> From: Al [mailto:n...@ridersite.org]
> Sent: Thursday, May 10, 2012 11:44 AM
> To: php-gene...@lists.php.net
> Subject: [PHP] Best practice question regarding set_include_path()
>
> For my applications, I've been using includes and other file addressing by
> using the doc root as the base dir.   e.g.
> require_once $_SERVER['DOCUMENT_ROOT'] .
> '/miniRegDB/includes/miniRegDBconfig.php';
>
> Recently, I ran into a problem with a new installation on a shared host
> where the doc root was assigned in an unusual manner. I rather not require
> setting a custom base dir [instead of $_SERVER['DOCUMENT_ROOT']'] for my
> applications.
>
> So, I was wondering if it would be good practice to use the
> set_include_path() and add the base dir for my applications.  I've used this
> for dealing with Pear function files on shared servers and had no problems.
>
> Need some guidance regarding this subject.
>
> Thanks....
>
> --
>
> I use define to set the application path
> define('BASE_PATH','C:\\inetpub\\vhosts\\yourwebsite.com\\httpdocs\\');
>
> Example:
> require_once (BASE_PATH. '/miniRegDB/includes/miniRegDBconfig.php');
>
>
> works great for JQuery paths
>
> <script>
> $(document).ready(function() {
> $('#dareport').html('<img src="<?php echo BASE_URL;?>images/loading.gif"
> />');
> });
> </script>
>
> To me it is much better than set_include_path() but works in the same
> premise
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

I tend to use a slightly more portable version:

define('APP_ROOT',dirname(__FILE__));

in a configuration file. (If the configuration file happens to be at a
different depth than the main application file(s), I stack on more
dirname's to get back to the application root.)

Similarly, I usually need an application URL path. This can be
trickier, depending on how you structure your application. This
generally works for the applications I develop:

define('APP_URL_BASE','http://'.$_SERVER['HOST_NAME'].dirname($_SERVER['SCRIPT_NAME']));

--- End Message ---

Reply via email to