Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Seth Foss

Jim Lucas wrote:

Seth Foss wrote:
  

Jim Lucas wrote:


Seth Foss wrote:
 
  

Hi everyone,

I am trying to run multiple sites on the same server, that have mostly
identical code - a pre-built application.

Anyway, I would like to save  disk space by specifying independent
configuration files for each site, then using symbolic links to access
the rest of the code for the application.

I have managed to configure apache so one such directory is accessed via
a symlink, which is ok. However, a file within the linked directory
attempts to include the configuration file (../config.php) from the
actual parent directory instead of the directory containing the symlink.

Is there any way to configure apache or php to trace back the symlink
when using '..', or can that only go one direction?

Thanks,
Seth




You can set the include path for your code to include the parent
directory
from where the symlink is and then remove the ../ part of the call.

  
  

Jim,

I had considered that, but I plan to have multiple directories following
symlinks to the same place.

For example,

/var/www/site1 has a config.php and a symlink to var/www/universal/app
while
/var/www/site2 has a different config.php and a symlink to
var/www/universal/app

var/www/universal/app has an index.php with include(../config.php) that
needs the config from the site that is using it (i.e., sometimes site1,
sometimes site2)

Does that make sense? Or did I misunderstand your suggestion?

Thanks,
Seth





You might have miss understood me.

In your VHOST entries, make an entry on each domain

VirtualHost X.X.X.X
DocumentRoot /path/to/example.com/public_html
ServerName example.com
php_value include_path '/path/to/example.com/public_html
/VirtualHost


Now you have your app symlinked into the public_html dir as such (guessing here)

ln -s /path/to/my/app /path/to/example.com/public_html/app

Now, in the app directory you have index.php that has include '../config.php';

Your problem is that the ../config.php reference refers to
/path/to/my/app/../config.php == /path/to/my/
instead of
/path/to/example.com/public_html/app/../config.php

Correct???

This is because it is being referenced logically from
/path/to/my/app/index.php

any symbolically from
/path/to/example.com/public_html/app/index.php

If that is the case, add the vHOST entry that I talked about above, then
reference the config file as include 'config.php';  and it will then look in
the include_path location(s) for the files and not think of referencing the
current directory that it is in.

Mind you that you can also enter this information into a .htaccess that is
located in the /path/to/example.com/public_html/ directory.  As long as
.htaccess files are allowed.

I usually have my include_path set to .:/path/to/example.com/public_html/ in
my vhosts entry for each domain.

Hope this helps
  
I did misunderstand. This approach is working for me. Unfortunately, as 
I am implementing it, it seems there are more files than I expected that 
utilize a series of '..'s instead of the absolute path from the config 
file, and more files than I expected that include the config file 
themselves.


However, these would cause me the same headaches with any of the 
proposed solutions.


Long story short, problem is solved. Setting the include path in VHOST 
lets me set it uniquely for each site, and then including config.php 
directly (no ..) uses that include path to grab the appropriate config file.


Thanks to everyone for your help, and especially you, Jim, for your 
elegant solution.


Seth

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Robert Cummings
On Thu, 2008-10-23 at 09:46 -0400, Seth Foss wrote:
 Jim Lucas wrote:
  Seth Foss wrote:

  Jim Lucas wrote:
  
  Seth Foss wrote:
   

  Hi everyone,
 
  I am trying to run multiple sites on the same server, that have mostly
  identical code - a pre-built application.
 
  Anyway, I would like to save  disk space by specifying independent
  configuration files for each site, then using symbolic links to access
  the rest of the code for the application.
 
  I have managed to configure apache so one such directory is accessed via
  a symlink, which is ok. However, a file within the linked directory
  attempts to include the configuration file (../config.php) from the
  actual parent directory instead of the directory containing the symlink.
 
  Is there any way to configure apache or php to trace back the symlink
  when using '..', or can that only go one direction?
 
  Thanks,
  Seth
 
  
  
  You can set the include path for your code to include the parent
  directory
  from where the symlink is and then remove the ../ part of the call.
 


  Jim,
 
  I had considered that, but I plan to have multiple directories following
  symlinks to the same place.
 
  For example,
 
  /var/www/site1 has a config.php and a symlink to var/www/universal/app
  while
  /var/www/site2 has a different config.php and a symlink to
  var/www/universal/app
 
  var/www/universal/app has an index.php with include(../config.php) that
  needs the config from the site that is using it (i.e., sometimes site1,
  sometimes site2)
 
  Does that make sense? Or did I misunderstand your suggestion?
 
  Thanks,
  Seth
 
 
  
 
  You might have miss understood me.
 
  In your VHOST entries, make an entry on each domain
 
  VirtualHost X.X.X.X
  DocumentRoot /path/to/example.com/public_html
  ServerName example.com
  php_value include_path '/path/to/example.com/public_html
  /VirtualHost
 
 
  Now you have your app symlinked into the public_html dir as such (guessing 
  here)
 
  ln -s /path/to/my/app /path/to/example.com/public_html/app
 
  Now, in the app directory you have index.php that has include 
  '../config.php';
 
  Your problem is that the ../config.php reference refers to
  /path/to/my/app/../config.php == /path/to/my/
  instead of
  /path/to/example.com/public_html/app/../config.php
 
  Correct???
 
  This is because it is being referenced logically from
  /path/to/my/app/index.php
 
  any symbolically from
  /path/to/example.com/public_html/app/index.php
 
  If that is the case, add the vHOST entry that I talked about above, then
  reference the config file as include 'config.php';  and it will then look in
  the include_path location(s) for the files and not think of referencing the
  current directory that it is in.
 
  Mind you that you can also enter this information into a .htaccess that is
  located in the /path/to/example.com/public_html/ directory.  As long as
  .htaccess files are allowed.
 
  I usually have my include_path set to .:/path/to/example.com/public_html/ 
  in
  my vhosts entry for each domain.
 
  Hope this helps

 I did misunderstand. This approach is working for me. Unfortunately, as 
 I am implementing it, it seems there are more files than I expected that 
 utilize a series of '..'s instead of the absolute path from the config 
 file, and more files than I expected that include the config file 
 themselves.
 
 However, these would cause me the same headaches with any of the 
 proposed solutions.
 
 Long story short, problem is solved. Setting the include path in VHOST 
 lets me set it uniquely for each site, and then including config.php 
 directly (no ..) uses that include path to grab the appropriate config file.
 
 Thanks to everyone for your help, and especially you, Jim, for your 
 elegant solution.

You could probably set a value in the vhost that makes the absolute path
to the web root available to your script. Personally, I hate to rely on
anything magical like non-standard include paths :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Jim Lucas
Robert Cummings wrote:
 On Thu, 2008-10-23 at 09:46 -0400, Seth Foss wrote:
 Jim Lucas wrote:
 Seth Foss wrote:
   
 Jim Lucas wrote:
 
 Seth Foss wrote:
  
   
 Hi everyone,

 I am trying to run multiple sites on the same server, that have mostly
 identical code - a pre-built application.

 Anyway, I would like to save  disk space by specifying independent
 configuration files for each site, then using symbolic links to access
 the rest of the code for the application.

 I have managed to configure apache so one such directory is accessed via
 a symlink, which is ok. However, a file within the linked directory
 attempts to include the configuration file (../config.php) from the
 actual parent directory instead of the directory containing the symlink.

 Is there any way to configure apache or php to trace back the symlink
 when using '..', or can that only go one direction?

 Thanks,
 Seth

 
 
 You can set the include path for your code to include the parent
 directory
 from where the symlink is and then remove the ../ part of the call.

   
   
 Jim,

 I had considered that, but I plan to have multiple directories following
 symlinks to the same place.

 For example,

 /var/www/site1 has a config.php and a symlink to var/www/universal/app
 while
 /var/www/site2 has a different config.php and a symlink to
 var/www/universal/app

 var/www/universal/app has an index.php with include(../config.php) that
 needs the config from the site that is using it (i.e., sometimes site1,
 sometimes site2)

 Does that make sense? Or did I misunderstand your suggestion?

 Thanks,
 Seth


 
 You might have miss understood me.

 In your VHOST entries, make an entry on each domain

 VirtualHost X.X.X.X
 DocumentRoot /path/to/example.com/public_html
 ServerName example.com
 php_value include_path '/path/to/example.com/public_html
 /VirtualHost


 Now you have your app symlinked into the public_html dir as such (guessing 
 here)

 ln -s /path/to/my/app /path/to/example.com/public_html/app

 Now, in the app directory you have index.php that has include 
 '../config.php';

 Your problem is that the ../config.php reference refers to
 /path/to/my/app/../config.php == /path/to/my/
 instead of
 /path/to/example.com/public_html/app/../config.php

 Correct???

 This is because it is being referenced logically from
 /path/to/my/app/index.php

 any symbolically from
 /path/to/example.com/public_html/app/index.php

 If that is the case, add the vHOST entry that I talked about above, then
 reference the config file as include 'config.php';  and it will then look in
 the include_path location(s) for the files and not think of referencing the
 current directory that it is in.

 Mind you that you can also enter this information into a .htaccess that is
 located in the /path/to/example.com/public_html/ directory.  As long as
 .htaccess files are allowed.

 I usually have my include_path set to .:/path/to/example.com/public_html/ 
 in
 my vhosts entry for each domain.

 Hope this helps
   
 I did misunderstand. This approach is working for me. Unfortunately, as 
 I am implementing it, it seems there are more files than I expected that 
 utilize a series of '..'s instead of the absolute path from the config 
 file, and more files than I expected that include the config file 
 themselves.

 However, these would cause me the same headaches with any of the 
 proposed solutions.

 Long story short, problem is solved. Setting the include path in VHOST 
 lets me set it uniquely for each site, and then including config.php 
 directly (no ..) uses that include path to grab the appropriate config file.

 Thanks to everyone for your help, and especially you, Jim, for your 
 elegant solution.
 
 You could probably set a value in the vhost that makes the absolute path
 to the web root available to your script. Personally, I hate to rely on
 anything magical like non-standard include paths :)
 
 Cheers,
 Rob.

You are probably right.

I was thinking, why could the app know its home and then also use just
DOCUMENT_ROOT?

I can't imagine a time that DOCUMENT_ROOT would not be correct, even from a
symlinked directory.

/app/index.php
?php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);

include ROOT . 'config.php';

...

?

You could also then use this ROOT constant else where in your code when you
need to refer to the website root path, instead of the app path

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-23 Thread Seth Foss

Jim Lucas wrote:

Robert Cummings wrote:
  

On Thu, 2008-10-23 at 09:46 -0400, Seth Foss wrote:


Jim Lucas wrote:
  

Seth Foss wrote:
  


Jim Lucas wrote:

  

Seth Foss wrote:
 
  


Hi everyone,

I am trying to run multiple sites on the same server, that have mostly
identical code - a pre-built application.

Anyway, I would like to save  disk space by specifying independent
configuration files for each site, then using symbolic links to access
the rest of the code for the application.

I have managed to configure apache so one such directory is accessed via
a symlink, which is ok. However, a file within the linked directory
attempts to include the configuration file (../config.php) from the
actual parent directory instead of the directory containing the symlink.

Is there any way to configure apache or php to trace back the symlink
when using '..', or can that only go one direction?

Thanks,
Seth



  

You can set the include path for your code to include the parent
directory
from where the symlink is and then remove the ../ part of the call.

  
  


Jim,

I had considered that, but I plan to have multiple directories following
symlinks to the same place.

For example,

/var/www/site1 has a config.php and a symlink to var/www/universal/app
while
/var/www/site2 has a different config.php and a symlink to
var/www/universal/app

var/www/universal/app has an index.php with include(../config.php) that
needs the config from the site that is using it (i.e., sometimes site1,
sometimes site2)

Does that make sense? Or did I misunderstand your suggestion?

Thanks,
Seth



  

You might have miss understood me.

In your VHOST entries, make an entry on each domain

VirtualHost X.X.X.X
DocumentRoot /path/to/example.com/public_html
ServerName example.com
php_value include_path '/path/to/example.com/public_html
/VirtualHost


Now you have your app symlinked into the public_html dir as such (guessing here)

ln -s /path/to/my/app /path/to/example.com/public_html/app

Now, in the app directory you have index.php that has include '../config.php';

Your problem is that the ../config.php reference refers to
/path/to/my/app/../config.php == /path/to/my/
instead of
/path/to/example.com/public_html/app/../config.php

Correct???

This is because it is being referenced logically from
/path/to/my/app/index.php

any symbolically from
/path/to/example.com/public_html/app/index.php

If that is the case, add the vHOST entry that I talked about above, then
reference the config file as include 'config.php';  and it will then look in
the include_path location(s) for the files and not think of referencing the
current directory that it is in.

Mind you that you can also enter this information into a .htaccess that is
located in the /path/to/example.com/public_html/ directory.  As long as
.htaccess files are allowed.

I usually have my include_path set to .:/path/to/example.com/public_html/ in
my vhosts entry for each domain.

Hope this helps
  

I did misunderstand. This approach is working for me. Unfortunately, as 
I am implementing it, it seems there are more files than I expected that 
utilize a series of '..'s instead of the absolute path from the config 
file, and more files than I expected that include the config file 
themselves.


However, these would cause me the same headaches with any of the 
proposed solutions.


Long story short, problem is solved. Setting the include path in VHOST 
lets me set it uniquely for each site, and then including config.php 
directly (no ..) uses that include path to grab the appropriate config file.


Thanks to everyone for your help, and especially you, Jim, for your 
elegant solution.
  

You could probably set a value in the vhost that makes the absolute path
to the web root available to your script. Personally, I hate to rely on
anything magical like non-standard include paths :)

Cheers,
Rob.



You are probably right.

I was thinking, why could the app know its home and then also use just
DOCUMENT_ROOT?

I can't imagine a time that DOCUMENT_ROOT would not be correct, even from a
symlinked directory.

/app/index.php
?php

define('ROOT', $_SERVER['DOCUMENT_ROOT']);

include ROOT . 'config.php';

...

?

You could also then use this ROOT constant else where in your code when you
need to refer to the website root path, instead of the app path

  
I am ashamed to say that so much have my php coding experience has been 
the modification of third-party apps that I never even knew the $_SERVER 
variable existed. Even if I had, I probably would have assumed that it 
would have given me the app path instead of the website path.


Tried it using Stut's snippet, and it works (not that they should be 
related, but just figured I'd mention that it works whether i added the 
include path to my VHOST or not).


Two great solutions! I 

[PHP] Difficulty navigating symlinks

2008-10-22 Thread Seth Foss

Hi everyone,

I am trying to run multiple sites on the same server, that have mostly 
identical code - a pre-built application.


Anyway, I would like to save  disk space by specifying independent 
configuration files for each site, then using symbolic links to access 
the rest of the code for the application.


I have managed to configure apache so one such directory is accessed via 
a symlink, which is ok. However, a file within the linked directory 
attempts to include the configuration file (../config.php) from the 
actual parent directory instead of the directory containing the symlink.


Is there any way to configure apache or php to trace back the symlink 
when using '..', or can that only go one direction?


Thanks,
Seth

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Robert Cummings
On Wed, 2008-10-22 at 11:59 -0400, Seth Foss wrote:
 Hi everyone,
 
 I am trying to run multiple sites on the same server, that have mostly 
 identical code - a pre-built application.
 
 Anyway, I would like to save  disk space by specifying independent 
 configuration files for each site, then using symbolic links to access 
 the rest of the code for the application.
 
 I have managed to configure apache so one such directory is accessed via 
 a symlink, which is ok. However, a file within the linked directory 
 attempts to include the configuration file (../config.php) from the 
 actual parent directory instead of the directory containing the symlink.
 
 Is there any way to configure apache or php to trace back the symlink 
 when using '..', or can that only go one direction?

Why not use CVS or SVN and just checkout the code? Sure you have it in
multiple places that way, but it's a cinch to deploy and allows rollback
to specific versions on any given tree.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Jim Lucas
Seth Foss wrote:
 Hi everyone,
 
 I am trying to run multiple sites on the same server, that have mostly
 identical code - a pre-built application.
 
 Anyway, I would like to save  disk space by specifying independent
 configuration files for each site, then using symbolic links to access
 the rest of the code for the application.
 
 I have managed to configure apache so one such directory is accessed via
 a symlink, which is ok. However, a file within the linked directory
 attempts to include the configuration file (../config.php) from the
 actual parent directory instead of the directory containing the symlink.
 
 Is there any way to configure apache or php to trace back the symlink
 when using '..', or can that only go one direction?
 
 Thanks,
 Seth
 

You can set the include path for your code to include the parent directory
from where the symlink is and then remove the ../ part of the call.

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Seth Foss

Robert Cummings wrote:

On Wed, 2008-10-22 at 11:59 -0400, Seth Foss wrote:
  

Hi everyone,

I am trying to run multiple sites on the same server, that have mostly 
identical code - a pre-built application.


Anyway, I would like to save  disk space by specifying independent 
configuration files for each site, then using symbolic links to access 
the rest of the code for the application.


I have managed to configure apache so one such directory is accessed via 
a symlink, which is ok. However, a file within the linked directory 
attempts to include the configuration file (../config.php) from the 
actual parent directory instead of the directory containing the symlink.


Is there any way to configure apache or php to trace back the symlink 
when using '..', or can that only go one direction?



Why not use CVS or SVN and just checkout the code? Sure you have it in
multiple places that way, but it's a cinch to deploy and allows rollback
to specific versions on any given tree.

Cheers,
Rob.
  
Thanks for the advice, Rob. I actually do have CVS and have been using 
it the way you describe. However, the sheer quantity of websites is 
beginning to overwhelm our disk space, especially when you consider that 
everything but the configuration is identical, and we do almost no 
modification to 95% of the code.


Anyway, if it isn't possible, then that's fine. I'm just trying to use 
our resources as efficiently as possible.


Does anyone have any other ideas?

Seth


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Seth Foss

Jim Lucas wrote:

Seth Foss wrote:
  

Hi everyone,

I am trying to run multiple sites on the same server, that have mostly
identical code - a pre-built application.

Anyway, I would like to save  disk space by specifying independent
configuration files for each site, then using symbolic links to access
the rest of the code for the application.

I have managed to configure apache so one such directory is accessed via
a symlink, which is ok. However, a file within the linked directory
attempts to include the configuration file (../config.php) from the
actual parent directory instead of the directory containing the symlink.

Is there any way to configure apache or php to trace back the symlink
when using '..', or can that only go one direction?

Thanks,
Seth




You can set the include path for your code to include the parent directory
from where the symlink is and then remove the ../ part of the call.

  

Jim,

I had considered that, but I plan to have multiple directories following 
symlinks to the same place.


For example,

/var/www/site1 has a config.php and a symlink to var/www/universal/app
while
/var/www/site2 has a different config.php and a symlink to 
var/www/universal/app


var/www/universal/app has an index.php with include(../config.php) that 
needs the config from the site that is using it (i.e., sometimes site1, 
sometimes site2)


Does that make sense? Or did I misunderstand your suggestion?

Thanks,
Seth


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Robert Cummings
On Wed, 2008-10-22 at 13:16 -0400, Seth Foss wrote:
 Robert Cummings wrote:
  On Wed, 2008-10-22 at 11:59 -0400, Seth Foss wrote:

  Hi everyone,
 
  I am trying to run multiple sites on the same server, that have mostly 
  identical code - a pre-built application.
 
  Anyway, I would like to save  disk space by specifying independent 
  configuration files for each site, then using symbolic links to access 
  the rest of the code for the application.
 
  I have managed to configure apache so one such directory is accessed via 
  a symlink, which is ok. However, a file within the linked directory 
  attempts to include the configuration file (../config.php) from the 
  actual parent directory instead of the directory containing the symlink.
 
  Is there any way to configure apache or php to trace back the symlink 
  when using '..', or can that only go one direction?
  
 
  Why not use CVS or SVN and just checkout the code? Sure you have it in
  multiple places that way, but it's a cinch to deploy and allows rollback
  to specific versions on any given tree.
 
  Cheers,
  Rob.

 Thanks for the advice, Rob. I actually do have CVS and have been using 
 it the way you describe. However, the sheer quantity of websites is 
 beginning to overwhelm our disk space, especially when you consider that 
 everything but the configuration is identical, and we do almost no 
 modification to 95% of the code.
 
 Anyway, if it isn't possible, then that's fine. I'm just trying to use 
 our resources as efficiently as possible.
 
 Does anyone have any other ideas?

What I do in almost all my projects is declare in a config someplace the
absolute path to the web tree on the filesystem something like:

$GLOBALS['interJinn']['pageRoot'] = '/path/to/website/pages/';

Then in weird cases like this I could use that to get the include path
since I know where my site is. In fact, you can even auto set the root
path using something like:

$GLOBALS['interJinn']['pageRoot'] = dirname( __FILE__ ).'/';

Then you don't even need to actually set it when you move your site
around as long as the config is in root. If the config isn't in the root
directory then just chop off directories from the end until you have the
root location.


HTH,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Jim Lucas
Seth Foss wrote:
 Jim Lucas wrote:
 Seth Foss wrote:
  
 Hi everyone,

 I am trying to run multiple sites on the same server, that have mostly
 identical code - a pre-built application.

 Anyway, I would like to save  disk space by specifying independent
 configuration files for each site, then using symbolic links to access
 the rest of the code for the application.

 I have managed to configure apache so one such directory is accessed via
 a symlink, which is ok. However, a file within the linked directory
 attempts to include the configuration file (../config.php) from the
 actual parent directory instead of the directory containing the symlink.

 Is there any way to configure apache or php to trace back the symlink
 when using '..', or can that only go one direction?

 Thanks,
 Seth

 

 You can set the include path for your code to include the parent
 directory
 from where the symlink is and then remove the ../ part of the call.

   
 Jim,
 
 I had considered that, but I plan to have multiple directories following
 symlinks to the same place.
 
 For example,
 
 /var/www/site1 has a config.php and a symlink to var/www/universal/app
 while
 /var/www/site2 has a different config.php and a symlink to
 var/www/universal/app
 
 var/www/universal/app has an index.php with include(../config.php) that
 needs the config from the site that is using it (i.e., sometimes site1,
 sometimes site2)
 
 Does that make sense? Or did I misunderstand your suggestion?
 
 Thanks,
 Seth
 
 

You might have miss understood me.

In your VHOST entries, make an entry on each domain

VirtualHost X.X.X.X
DocumentRoot /path/to/example.com/public_html
ServerName example.com
php_value include_path '/path/to/example.com/public_html
/VirtualHost


Now you have your app symlinked into the public_html dir as such (guessing here)

ln -s /path/to/my/app /path/to/example.com/public_html/app

Now, in the app directory you have index.php that has include '../config.php';

Your problem is that the ../config.php reference refers to
/path/to/my/app/../config.php == /path/to/my/
instead of
/path/to/example.com/public_html/app/../config.php

Correct???

This is because it is being referenced logically from
/path/to/my/app/index.php

any symbolically from
/path/to/example.com/public_html/app/index.php

If that is the case, add the vHOST entry that I talked about above, then
reference the config file as include 'config.php';  and it will then look in
the include_path location(s) for the files and not think of referencing the
current directory that it is in.

Mind you that you can also enter this information into a .htaccess that is
located in the /path/to/example.com/public_html/ directory.  As long as
.htaccess files are allowed.

I usually have my include_path set to .:/path/to/example.com/public_html/ in
my vhosts entry for each domain.

Hope this helps

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Yeti
If you are in control of you DNS records you could CNAME [1] the sites
to the same address, where a PHP script or RewriteRule [2] loads the
specific configuration by checking the requested URI. Since you got
them on the same server anyways this would not cost any performance.

[1] http://www.zytrax.com/books/dns/ch8/cname.html
[2] http://marc.info/?l=php-generalm=122383066714789w=2

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Difficulty navigating symlinks

2008-10-22 Thread Stut

On 22 Oct 2008, at 18:16, Seth Foss wrote:

Robert Cummings wrote:

On Wed, 2008-10-22 at 11:59 -0400, Seth Foss wrote:


Hi everyone,

I am trying to run multiple sites on the same server, that have  
mostly identical code - a pre-built application.


Anyway, I would like to save  disk space by specifying independent  
configuration files for each site, then using symbolic links to  
access the rest of the code for the application.


I have managed to configure apache so one such directory is  
accessed via a symlink, which is ok. However, a file within the  
linked directory attempts to include the configuration file (../ 
config.php) from the actual parent directory instead of the  
directory containing the symlink.


Is there any way to configure apache or php to trace back the  
symlink when using '..', or can that only go one direction?




Why not use CVS or SVN and just checkout the code? Sure you have it  
in
multiple places that way, but it's a cinch to deploy and allows  
rollback

to specific versions on any given tree.

Cheers,
Rob.

Thanks for the advice, Rob. I actually do have CVS and have been  
using it the way you describe. However, the sheer quantity of  
websites is beginning to overwhelm our disk space, especially when  
you consider that everything but the configuration is identical, and  
we do almost no modification to 95% of the code.


Anyway, if it isn't possible, then that's fine. I'm just trying to  
use our resources as efficiently as possible.


Does anyone have any other ideas?


Check $_SERVER - there's almost certainly a var in there that can help  
you get the right absolute path. $_SERVER['DOCUMENT_ROOT'] springs to  
mind but whether it's right depends on how your web server is  
configured. Create a script with just the following code to see what's  
there...


pre?php print_r($_SERVER); ?/pre

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php