• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

How to include php files that are not sitting in the document root of a web site?

Dear all,

I have a library of php files that I would like to use in several web sites.

I thus have several directories, one for each web site, containing the different web sites files.

The directories look like this:

/home/httpd/vhosts/website1.net/httpdocs/

or like this

/home/httpd/vhosts/website2.net/httpdocs/

I would like to avoid ducplicating the library of php files in these different web sites directories.

I would prefer to keep only one copy of these library php files on the server.

The server is a dedicated server.

The library is sitting in the directory

/home/httpd/vhosts/website0.net/httpdocs/engine/lib

but it could sit anywhere on the server file system.

I tried to use ymbolic links to have the lib/ directory present in the other directories.

Also, the open_basedir in the php.ini file is empty:

;open_basedir =

But when accessing the web site I get this message:

Warning: Unknown(): open_basedir restriction in effect. File(/home/httpd/vhosts/thalasoft.net/httpdocs/engine/index.php) is not within the allowed path(s): (/home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs:/tmp) in Unknown on line 0

Warning: Unknown(/home/httpd/vhosts/thalasoft.net/httpdocs/engine/index.php): failed to open stream: Opération non permise in Unknown on line 0

Warning: (null)(): Failed opening '/home/httpd/vhosts/thalasoft.net/httpdocs/engine/index.php' for inclusion (include_path=':/home/httpd/vhosts/thalasoft.net/httpdocs/engine/setup') in Unknown on line 0


How to include php files that are not sitting in the document root of a web site?

Kind Regards
Stephane

0
stephaneeybert
Asked:
stephaneeybert
  • 38
  • 13
  • 5
  • +2
1 Solution
 
kenfcampCommented:
using > include ("/home/httpd/vhosts/thalasoft.net/httpdocs/engine/index.php"); < should work just fine.

alternatly you could also use > include ("http://www.somesite.com/engine/index.php");

There are potential problems with either of these solutions however. "IF" the desired file to be included calls other files there is a good chance you will get errors as the files needed will be not be in the directory path of the current site.

What I woud do is create a directory that can be used by all domains if desired such as a static cgi-bin directory (ex -- engine) and place the desired and associated files/directories there.

This would allow all your domains to use the scripts if needed (http://www.somesite.com/engine/)

Good luck

0
 
mrielfCommented:
Turn off safe mode in php

http://www.php.net/features.safe-mode
0
 
stephaneeybertAuthor Commented:
kenfcamp, I create the directory, I put the library files in it, but then... What should I do to use them...?

Something to note is that all my files have the following statement:

require_once("website.php");

I use for this a php include_path directive.

Thanks!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
stephaneeybertAuthor Commented:
My safe_mode is already off.

Here is a snippet of my php.ini

; Safe Mode
;
safe_mode = Off

; By default, Safe Mode does a UID compare check when
; opening files. If you want to relax this to a GID compare,
; then turn on safe_mode_gid.
safe_mode_gid = Off

; When safe_mode is on, UID/GID checks are bypassed when
; including files from this directory and its subdirectories.
; (directory must also be in include_path or full path must
; be used when including)
safe_mode_include_dir =


Thanks
0
 
stephaneeybertAuthor Commented:
I tried this in the php.ini file:

safe_mode_include_dir = /home/httpd/vhosts/thalasoft.net/httpdocs

and restarted the Apache server.

But the error message is the same.

0
 
periwinkleCommented:
An alternative would be to create a Alias for your libraries in your Apache VirtualHosts.  Add a line that looks like:

Alias /mylib /home/httpd/vhosts/website0.net/httpdocs/engine/lib

restart Apache, and then you can access the lbraries as:

mylib/filename
0
 
stephaneeybertAuthor Commented:
Should I have this line anywhere in the httpd.conf file..?

I'll try...

Thanks!

0
 
periwinkleCommented:
Put it within your virtualhost.
0
 
stephaneeybertAuthor Commented:
I did this in my httpd.conf file:

Alias /engine "/home/httpd/vhosts/website0.net/httpdocs/engine"

<Directory "/home/httpd/vhosts/website0.net/httpdocs/engine">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


I also set the open_basedir variable like this for /home/httpd/vhosts/website1.net/httpdocs/

php_admin_value open_basedir "/home/httpd/vhosts/website1.net:/tmp"



The problem now is that when accessing

http://www.website1.net/index.php the browser displays a popup window and I can save the php script containing the source code.

Any clue..?

Thanks!

Stephane

0
 
stephaneeybertAuthor Commented:
Wouldn't it be better to use ScriptAlias instead..?
0
 
stephaneeybertAuthor Commented:
No, I tried ScriptAlias and it is worse.
0
 
stephaneeybertAuthor Commented:
Sorry for my ignorance. Are you talking of the virtual host tags of the website0.net web site or website1.net web site..?

Would you have an example..?

Thanks
0
 
stephaneeybertAuthor Commented:
It's funny because
http://demo.thalasoft.net/phpinfo.php
is correctly parsed and displayed.

Whereas
http://demo.thalasoft.net/index.php
pops up a dialog box to offer to save the file index.php

As a reminder the file index.php is a link:
index.php -> ../../../httpdocs/index.php

Is it the reason fot the no parsing...?

0
 
stephaneeybertAuthor Commented:
I did some testing, and the files are correctly parsed if the link sits in the same document root than its target.

Otherwise the target php script file is offered for download instead of being parsed.

0
 
stephaneeybertAuthor Commented:
If the index.php file points to a whoami.php file

lrwxrwxrwx  1 thalasoft psacln   28 oct 25 21:05 index.php -> ../../../httpdocs/whoami.php

then the result if fine:

HOSTNAME demo.website0.net
DOCUMENT_ROOT /home/httpd/vhosts/website0.net/subdomains/demo/httpdocs
PHP_SELF /index.php

0
 
periwinkleCommented:
I meant within the <VirtualHost> container.

I wouldn't use the relative paths of ../../../ because if you relocate any of the directories, everything can easily be thrown off.  

You definitely don't want ScriptAlias.  You want Alias, because that is saying 'pretend that this directory is available, relative from the DocumentRoot of this VirtualHost.

An example:


<VirtualHost xxx.xxx.xxx.xxx:80>
     ServerName www.website1.net
     ServerAlias website1.net
     Alias /mylib /home/httpd/vhosts/website0.net/httpdocs/engine/lib
     DocumentRoot /home/httpd/vhosts/website1.net/httpdocs/
     <Directory /home/httpd/vhosts/website1.net/httpdocs/>
          Options Includes FollowSymLinks
          AllowOverride All
          order allow,deny
          allow from all
     </Directory>
     <Directory /home/httpd/vhosts/website1.net/httpdocs/cgi-bin>
          Options FollowSymLinks Includes
          order allow,deny
          allow from all
          <Limit GET POST>
               order allow,deny
               allow from all
          </Limit>
     </Directory>
     ScriptAlias /cgi-bin/ /home/httpd/vhosts/website1.net/httpdocs/cgi-bin/
</VirtualHost>


0
 
stephaneeybertAuthor Commented:
Here is my Virtual Host:


VirtualHost 62.193.225.224:80>
        ServerName   demo.thalasoft.net:80                                                        ServerAdmin  "mittiprovence@yahoo.se"                                                     DocumentRoot /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs                    CustomLog  /home/httpd/vhosts/thalasoft.net/statistics/logs/access_log combined           ErrorLog   /home/httpd/vhosts/thalasoft.net/statistics/logs/error_log                     <IfModule mod_ssl.c>                                                                              SSLEngine off                                                                     </IfModule>                                                                               <Directory  /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs>                    <IfModule sapi_apache2.c>                                                                         php_admin_flag engine on                                                                  php_admin_value open_basedir "/home/httpd/vhosts/thalasoft.net:/tmp"              </IfModule>                                                                                       Options FollowSymLinks Includes -ExecCGI                                                  AllowOverride All                                                                         order allow,deny                                                                          allow from all                                                                    </Directory>

<Directory /home/httpd/vhosts/thalasoft.net/httpdocs/cgi-bin>                                       Options FollowSymLinks Includes                                                           order allow,deny                                                                          allow from all                                                                            <Limit GET POST>                                                                               order allow,deny                                                                          allow from all                                                                       </Limit>
     </Directory>
     ScriptAlias /cgi-bin/ /home/httpd/vhosts/thalasoft.net/httpdocs/cgi-bin/

</VirtualHost>

But the request http://demo.thalasoft.net/index.php displays a popup window
instead of parsing the index.php file...

0
 
stephaneeybertAuthor Commented:
The popup window no parsing issue occurs only with sym links.
0
 
stephaneeybertAuthor Commented:
And only when the link target sits in another document root
0
 
stephaneeybertAuthor Commented:
Here is my vhost
<VirtualHost 62.193.225.224:80>
        ServerName   thalasoft.net:80
        ServerAlias  www.thalasoft.net
        UseCanonicalName Off
        ServerAdmin  "mittiprovence@yahoo.se"
        DocumentRoot /home/httpd/vhosts/thalasoft.net/httpdocs
        CustomLog  /home/httpd/vhosts/thalasoft.net/statistics/logs/access_log combined
        ErrorLog   /home/httpd/vhosts/thalasoft.net/statistics/logs/error_log
<IfModule mod_userdir.c>
        UserDir /home/httpd/vhosts/thalasoft.net/web_users
</IfModule>
        <IfModule mod_ssl.c>
                SSLEngine off
        </IfModule>
        <Directory /home/httpd/vhosts/thalasoft.net/httpdocs>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
                php_admin_value open_basedir "/home/httpd/vhosts/thalasoft.net/httpdocs:/tmp"
        </IfModule>
                Options -Includes -ExecCGI
        </Directory>
</VirtualHost>
<VirtualHost 62.193.225.224:80>
        ServerName   demo.thalasoft.net:80
        ServerAdmin  "mittiprovence@yahoo.se"
        DocumentRoot /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs
        CustomLog  /home/httpd/vhosts/thalasoft.net/statistics/logs/access_log combined
        ErrorLog   /home/httpd/vhosts/thalasoft.net/statistics/logs/error_log
        <IfModule mod_ssl.c>
                SSLEngine off
        </IfModule>
        <Directory  /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
                php_admin_value open_basedir "/home/httpd/vhosts/thalasoft.net:/tmp"
        </IfModule>
                Options -Includes -ExecCGI
        </Directory>
</VirtualHost>

The web site demo.thalasoft.net uses some library files that sit in the web site thalasoft.net

[root@wpc0797 httpdocs]# ll
total 8
drwxr-xr-x  4 thalasoft psacln 4096 oct 22 09:12 account
lrwxrwxrwx  1 thalasoft psacln   27 oct 25 21:13 admin.php -> ../../../httpdocs/admin.php
lrwxrwxrwx  1 thalasoft psacln   27 oct 25 21:11 index.php -> ../../../httpdocs/index.php
-rwxrwxrwx  1 thalasoft psacln   29 oct 22 09:31 phpinfo.php
lrwxrwxrwx  1 thalasoft psacln   28 oct 25 21:04 whoami.php -> ../../../httpdocs/whoami.php

0
 
periwinkleCommented:
What I would suggest is to move (or copy) admin.php, index.php, and whoami.php in a directory called lib, i.e.:

/home/httpd/vhosts/thalasoft.net/httpdocs/lib

Then, you could modify the VirtualHost for the demo.thalasoft.net as follows:

<VirtualHost 62.193.225.224:80>
        ServerName   demo.thalasoft.net:80
        ServerAdmin  "mittiprovence@yahoo.se"
        DocumentRoot /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs
        CustomLog  /home/httpd/vhosts/thalasoft.net/statistics/logs/access_log combined
        ErrorLog   /home/httpd/vhosts/thalasoft.net/statistics/logs/error_log
        Alias /mylib /home/httpd/vhosts/thalasoft.net/httpdocs/lib
        <IfModule mod_ssl.c>
                SSLEngine off
        </IfModule>
        <Directory  /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
                php_admin_value open_basedir "/home/httpd/vhosts/thalasoft.net:/tmp"
        </IfModule>
                Options -Includes -ExecCGI
        </Directory>
</VirtualHost>

restart the server (necessary to reload the httpd.conf file).

Then, refer to the files as /mylib/admin.php, /mylib/index.php, and /mylib/whoami.php .
0
 
stephaneeybertAuthor Commented:
I added the line

Alias /mylib /home/httpd/vhosts/thalasoft.net/httpdocs/engine

to the file.

But I still get a popup window offering to download the php file...

The script is found only it is not parsed...

0
 
stephaneeybertAuthor Commented:
But calling this file

lrwxrwxrwx  1 thalasoft psacln   52 oct 26 00:15 whoami.php -> /home/httpd/vhosts/thalasoft.net/httpdocs/whoami.php

with http://demo.thalasoft.net/whoami.php

works fine, the php script is parsed.

0
 
periwinkleCommented:
After adding the Alias, how are you referring to the script?
0
 
stephaneeybertAuthor Commented:
This poses the same problem:

lrwxrwxrwx  1 thalasoft psacln   58 oct 26 00:18 whoami.php -> /home/httpd/vhosts/thalasoft.net/httpdocs/engine/index.php

http://demo.thalasoft.net/whoami.php


0
 
stephaneeybertAuthor Commented:
But this works fine:

lrwxrwxrwx  1 thalasoft psacln   59 oct 26 00:20 whoami.php -> /home/httpd/vhosts/thalasoft.net/httpdocs/engine/whoami.php

with http://demo.thalasoft.net/whoami.php

0
 
stephaneeybertAuthor Commented:
It is the content of index.php that poses problem.

Here it is:

<?php

require_once("website.php");

require_once($gFlashPath . "displayIntro.php");

?>
0
 
stephaneeybertAuthor Commented:
My include_path in phpµ.ini

include_path = ":/home/httpd/vhosts/thalasoft.net/httpdocs/engine/setup"

And the content of setup/

[root@wpc0797 engine]# ll setup/
total 32
-rw-r--r--  1 thalasoft psacln  790 oct 22 09:21 database.php
-rw-r--r--  1 thalasoft psacln  433 oct 14 15:48 env.php
-rw-r--r--  1 thalasoft psacln  514 oct 14 16:10 host.php
-rw-r--r--  1 thalasoft psacln  686 oct 14 15:48 library.php
-rw-r--r--  1 thalasoft psacln 4366 oct 21 13:35 path.php
-rw-r--r--  1 thalasoft psacln 1161 oct 14 16:24 system.php
-rw-r--r--  1 thalasoft psacln  539 oct 14 16:17 website.php
0
 
stephaneeybertAuthor Commented:
I call the script like this:

http://demo.thalasoft.net/index.php
0
 
stephaneeybertAuthor Commented:
I'm off to bed, it's late here in south of France.

Thanks!

0
 
mrielfCommented:
Stephan!
The alias thing isn't working because the php script isn't interpreted in apache.
If safe mode is off, then you can specify scripts out of basedir.
Specify exact location of the script witch you want to include.
If it isn't works for you, then might be there other things  like php/apache runs in jail etc...
0
 
stephaneeybertAuthor Commented:

My safe mode is off.

0
 
periwinkleCommented:
As website.php is in the mylib aliased directory, you then have to specify that path after setting up the alias:


<?php

require_once("mylib/website.php");

require_once($gFlashPath . "displayIntro.php");

?>

0
 
stephaneeybertAuthor Commented:
Hi mrielf ,

Here is my engine/ library /home/httpd/vhosts/thalasoft.net/httpdocs/engine

and the setup is:

<Directory "/home/httpd/vhosts/thalasoft.net/httpdocs/engine">
    Options -Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

0
 
stephaneeybertAuthor Commented:
This http://www.thalasoft.net/engine/ajeter.php is parsed fine.

This http://demo.thalasoft.net/engine/ajeter.php displays a download popup.

And the file is sitting in

/home/httpd/vhosts/thalasoft.net/httpdocs/engine/ajeter.php

and contains

<?PHP

print("Parsed!");

?>

Any clue?

0
 
stephaneeybertAuthor Commented:
Sorry but I need to clear things up here..

periwinkle, is it true as mrielf is saying that :
The alias thing isn't working because the php script isn't interpreted in apache ?

0
 
periwinkleCommented:
Stephanie -

I think that the alias thing is a separate issue from the PHP being interpretted.

If PHP isn't being interpretted, it sounds like perhaps safe-mode IS set on in some manner, or that other security checks are causing the issue as mrielf has indicated.

Have you looked through the safe_mode configuration directives here:

http://us2.php.net/features.safe-mode

and compared to those in your php.ini to see if there is something there that is preventing the php from outside your directory from working properly?
0
 
stephaneeybertAuthor Commented:
I think also that the Alias is another issue.

I will check again my safe mode setup.

In my php.ini I currently have:

safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
open_basedir = /home/httpd/vhosts/



0
 
stephaneeybertAuthor Commented:
My safe mode seen through phpinfo()

safe_mode      Off      Off
safe_mode_exec_dir      no value      no value
safe_mode_gid      Off      Off
safe_mode_include_dir      no value      no value
0
 
stephaneeybertAuthor Commented:
I also have this setup sitting in the file /home/httpd/vhosts/thalasoft.net/conf/httpd.include

<VirtualHost 62.193.225.224:80>
        ServerName   thalasoft.net:80
        ServerAlias  www.thalasoft.net
        UseCanonicalName Off
        ServerAdmin  "mittiprovence@yahoo.se"
        DocumentRoot /home/httpd/vhosts/thalasoft.net/httpdocs
        CustomLog  /home/httpd/vhosts/thalasoft.net/statistics/logs/access_log combined
        ErrorLog   /home/httpd/vhosts/thalasoft.net/statistics/logs/error_log
<IfModule mod_userdir.c>
        UserDir /home/httpd/vhosts/thalasoft.net/web_users
</IfModule>
        <IfModule mod_ssl.c>
                SSLEngine off
        </IfModule>
        <Directory /home/httpd/vhosts/thalasoft.net/httpdocs>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
                php_admin_value open_basedir "/home/httpd/vhosts/thalasoft.net:/tmp"
        </IfModule>
        Options -Includes -ExecCGI
        </Directory>
</VirtualHost>

<VirtualHost 62.193.225.224:80>
        ServerName   demo.thalasoft.net:80
        ServerAdmin  "mittiprovence@yahoo.se"
        DocumentRoot /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs
        CustomLog  /home/httpd/vhosts/thalasoft.net/statistics/logs/access_log combined
        ErrorLog   /home/httpd/vhosts/thalasoft.net/statistics/logs/error_log
        Alias /engine /home/httpd/vhosts/thalasoft.net/httpdocs/engine
        <IfModule mod_ssl.c>
                SSLEngine off
        </IfModule>
        <Directory  /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
                php_admin_value open_basedir "/home/httpd/vhosts/thalasoft.net:/tmp"
        </IfModule>
                Options -Includes -ExecCGI
        </Directory>
</VirtualHost>
0
 
stephaneeybertAuthor Commented:
You may note that I never saw this message seen on your page http://us2.php.net/features.safe-mode :

Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not
allowed to access /etc/passwd owned by uid 0 in /docroot/script.php on line 2

Not once!

So it might not be a safe mode issue after all...


0
 
periwinkleCommented:
Have you set an open_basedir by any chance?
0
 
stephaneeybertAuthor Commented:
The script

http://www.thalasoft.net/engine/safe_mode.php

containing

<?php

// Check for safe mode
if( ini_get('safe_mode') ){
  print("Safe mode is ON");
  }else{
  print("Safe mode is OFF");
  }

?>

displays

Safe mode is OFF

0
 
periwinkleCommented:
I see your point... have you checked the error_log?

According to here:

http://us2.php.net/manual/en/function.require.php

require should result in a fatal error, whereas include should continue even if it can't execute.  What happens when you use include?

Have you tried setting the return value to a variable and printing that out?

see: http://us2.php.net/manual/en/function.include.php

0
 
mrielfCommented:
Here is a part from my httpd.conf:

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@xxxxxxxxxxx
    DocumentRoot /usr/share/web
    ServerName teszt
    alias /mr/ /var/www/mr/
    ErrorLog /var/log/apache/avivanet.hu-error.log
    CustomLog /var/log/apache/avivanet.hu-access.log common
</VirtualHost>

a part from php.ini:

safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =        
safe_mode_exec_dir =

safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH

;open_basedir =

disable_functions =
disable_classes =

;include_path = ".:/usr/share/pear"


This index.php is sitting in /var/www/mr :

<?php
require_once("/mylib/include.php");
?>

This included file (include.php) is sitting in /mylib

<?php
echo "hello";
?>


when i requesting http://server/mr/index.php it displays "hello" (The include was sucessfull)

So, the "/mylib" isn't  noticet on another place that in the index.php and it works...
You need nothing, if the Safe Mode is off...

0
 
stephaneeybertAuthor Commented:
Thanks to you all.

But in my example, there are no include statements...

This http://www.thalasoft.net/engine/ajeter.php is parsed fine.

This http://demo.thalasoft.net/engine/ajeter.php displays a download popup.

And the file is sitting in

/home/httpd/vhosts/thalasoft.net/httpdocs/engine/ajeter.php

and contains

<?PHP

print("Parsed!");

?>

0
 
stephaneeybertAuthor Commented:
And now I have an open_basedir restriction in effect.

That is because Plesk overwrites my conf/httpd.include file and sets anew the open_basedir variable.

0
 
periwinkleCommented:
Ahah!  That's the problem.

From http://us2.php.net/features.safe-mode :

open_basedir  string

    Limit the files that can be opened by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off.

    When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink.

(...)

 In httpd.conf, open_basedir can be turned off (e.g. for some virtual hosts) the same way as any other configuration directive with "php_admin_value open_basedir none".

This also contains a link to here:

http://us2.php.net/manual/en/configuration.changes.php#configuration.changes.apache

which shows how to place these directives.

0
 
mrielfCommented:
Sorry I very misunderstood You...

Of course you must use "alias" in this situation, but it looks like the problem exist at Virtual Host part...

One moment I investigate it...
0
 
mrielfCommented:
I think periwinkle got the answer...

Sorry for bad information from me... :) I totaly misunderstood your problem...

0
 
mogrifyCommented:
Although this might be a moot point after so many determined efforts to solve this, you might be able to achieve the same effect by bind-mounting the directory with the scripts in it it to the appropriate directories in the other hosts, like this:

mount --bind /home/httpd/vhosts/website0.net/httpdocs/engine/lib /home/httpd/vhosts/website1.net/httpdocs/engine/lib

and so on... the result is that the new directories are truly part of the filesystem and not outside the allowed directory tree.  I haven't tested this with php but I use it to make my web directory (/var/www/localhost/htdocs) accessible from my home folder when I log in via FTP (which also doesn't follow symlinks and the like).  Of course you need root access and kernel>=2.4.  For more info do `man mount`.
0
 
stephaneeybertAuthor Commented:
I found out how to do it.

In the conf/ directory of the virtual host, create a file vhost.conf containing:

<Directory /home/httpd/vhosts/thalasoft.net/httpdocs>
php_admin_value open_basedir none
</Directory>

Then run the command:

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=mywebsite.com

Then restart Apache.

And it works fine!

I would like to do the same thing for a sub domain this time (instead of a domain).

Any idea..?

Cheers

Stephane
0
 
periwinkleCommented:
Stephanie -

Congrats on the solution to your original problem!

You can set up a subdomain the same way that you set up a domain -- through a virtualhost:

<VirtualHost xxx.xxx.xxx.xxx:80>
        ServerName   mysubdomain.thalasoft.net:80
        DocumentRoot /home/httpd/vhosts/thalasoft.net/subdomains/mysubdomain/httpdocs

       (...)

        <Directory  /home/httpd/vhosts/thalasoft.net/subdomains/mysubdomain/httpdocs>
         php_admin_value open_basedir none
        </Directory>
</VirtualHost>


Then run the command:

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=mysubdomain.mywebsite.com

and restart Apache.

... should work just the same!

0
 
stephaneeybertAuthor Commented:
The setup cannot be placed inside the <VirtualHost> tags as they are generated by Plesk.

Each time Plesk 7 is restarted, it recreates the http.include file for each domain.

Therefore the use of the vhost.conf files.

I'll try your suggestion though.

Back to you soon!
0
 
stephaneeybertAuthor Commented:
I added this:

<Directory /home/httpd/vhosts/thalasoft.net/subdomains/demo/httpdocs>
php_admin_value open_basedir /home/httpd/vhosts
</Directory>

in the vhost.conf file of the domain name.

And ran the command:

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=mysubdomain.mywebsite.com

and restarted Apache.

But the open_basedir was not modified at all.

Thanks for the effort!

Stephane
0
 
periwinkleCommented:
hmmm - I'm not familiar with how to get around Plesk - sorry!  I do my configurations by hand :)
0
 
stephaneeybertAuthor Commented:
No worries! Thanks for your support!
0
 
periwinkleCommented:
Stephanie -

You're very kind - I'm glad that you problem has been solved, and hope you can quickly get beyond the Plesk issue as well.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 38
  • 13
  • 5
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now