• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

modifying php basedir

S

snelson100

Guest
Hi Folks,

I'm wanting to create a directory for my users that is accessible by php but would not be served up by apache.

To make this change for just one user I am tempted to just modify this line:
php_admin_value open_basedir "/home/httpd/vhosts/webqualityhost.net/httpsdocs:/tmp"
in his httpd.include file. But at the very start of that file it says:
# ATTENTION!
# DO NOT MODIFY THIS FILE OR ANY PART OF IT. THIS CAN RESULT IN IMPROPER PLESK
# FUNCTIONING OR FAILURE, CAUSE DAMAGE AND LOSS OF DATA. IF YOU REQUIRE CUSTOM
# MODIFICATIONS TO BE APPLIED TO THE CONFIGURATION, PLEASE, PERFORM THEM IN THE
# FOLLOWING FILE(S):
# /home/httpd/vhosts/host/conf/vhost.conf
# /home/httpd/vhosts/host/conf/vhost_ssl.conf
# /home/httpd/vhosts/subdomains/<subdomain-name>/conf/vhost.conf

So I do that instead and nothing happens, the basedir stays the same. I have restarted apache and that doesn't seem to cause it to recognize the change either... so what am I doing wrong? How do I modify the basedir for my user?
 
That seems to have no effect - phpinfo() still reports the old basedir. Even after I ran websrvmng as instructed...
 
Try something like the following in your domain's conf/vhost.conf:

<Directory /home/httpd/vhosts/DOMAINNAME/httpdocs>
php_admin_value safe_mode 0
</Directory>
 
No I never got it figured out. Please do post a message here if you figure it out.
 
Ok, here's the scoop on subdomains

It appears that what Plesk has done for subdomains is the following:

They create <Directory > entries in the main domain's http.include file:

/home/httpd/vhosts/domain.com/conf/vhost.conf

But they do NOT put an Include line to include the subdomain's vhost.conf file until after you create it and then run the /usr/local/psa/admin/sbin/websrvmng -u --vhost-name=maindomain.com

They put the Include directive after this, at the bottom of the <VirtualHost> section.

So once you create your vhost.conf file with something like:

# This is just an example, you will need to change the open_basedir paths to your needs
<Directory /home/httpd/vhosts/maindomain.com/subdomains/subdomname/httpdocs>
php_admin_flag engine on
php_admin_value register_globals 1
php_admin_value safe_mode 0
php_admin_value open_basedir /home/httpd/vhosts/maindomain.com/subdomains/subdomname/httpdocs:/tmp:/usr/share/pear
</Directory>


The vhost.conf file should be located at:
/home/httpd/vhosts/maindomain.com/subdomains/subdomname/conf/vhost.conf

Then run:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=maindomain.com

And then RESTART APACHE ('service httpd restart' or '/etc/rc.d/init.d/httpd restart' or whatever your OS command would be)

Your open_basedir changes should then take effect. If not, then check the httpd.include file to make sure the Include line was added.

Since the Include line is below their default open_basedir statement in httpd.include, yours in the vhost.conf file will take precedence since it is processed after the httpd.include lines.

I have tested this several times with different subdomains and open_basedir paths. In each case, my vhost.conf lines show up when I run phpinfo.php from the subdomain httpdocs directory.

Hope this helps clear things up.
 
That worked. Thanks so much. The missing piece of information was this:

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

The "/usr/local/psa/admin/sbin/websrvmng -a -v" that the faq says to do just isn't the right command.

Thanks a lot!
 
OK - this makes about ZERO sense to me. I'm not going to question it, because it works, but ...

All you've done in your edited post above is to reiterate the steps that I've been doing for many, many hours now.

jamesyeeoc - your post, before you edited it, gave me new information to try (that didn't work) - then you edited it to not include the part about manually editing the httpd.include file - which was the only new part for me - and now all of the sudden, after I just try it again, it works. Bloody Hell.

I F'ING hate computers sometimes. I know, I know, it's just me - I was obviously doing something wrong before.

jamesyeeoc - thanks SO much for your time and effort in helping with this. If I could afford to paypal you some $$ I would :) One day ...

Now if I could only get this to work NOT within a subdomain ;) No, don't try to help, I'll figure it out eventually.

Cheers y'all.
 
Basically my original instructions were to manually edit the domain's httpd.include file which the websrvmng command will modify anyways. So I just cleaned it up and made use of the Plesk provided utility to be more conforming to Plesk.

The instructions as currently posted pretty much do the same thing, it's just a cleaner implementation.

To do the same for the main domain, you just have to create the vhost.conf file:

# This is just an example, you will need to change the open_basedir paths to your needs
<Directory /home/httpd/vhosts/maindomain.com/httpdocs>
php_admin_flag engine on
php_admin_value register_globals 1
php_admin_value safe_mode 0
php_admin_value open_basedir /home/httpd/vhosts/maindomain.com/httpdocs:/tmp:/usr/share/pear
</Directory>

The vhost.conf file should be located at:
/home/httpd/vhosts/maindomain.com/conf/vhost.conf

Then run:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=maindomain.com

And then RESTART APACHE ('service httpd restart' or '/etc/rc.d/init.d/httpd restart' or whatever your OS command would be)

Your open_basedir changes should then take effect. If not, then check the httpd.include file to make sure the Include line was added.

By the way, the register_globals and safe_mode lines are optional and should only be included for domains which require them. Basically they turn register_globals ON and safe_mode OFF. This is NOT needed for all domains, just was part of my example code...

Another note: Often I have found that clearing the browser cache will sometimes help after making these types of changes to a domain or subdomain. I notice it a lot with Firefox and to a lesser degree with IE. Maybe this is why it 'suddenly' began working for you, the browser cache expired and refreshed. Who can say?
 
By chance does anyone know if the vhost.conf for subdomains outlined above work for Plesk verion 7.0.4 ?

Thanks,
- D
 
The actual vhost.conf statements are not Plesk specific, but are Apache related, so should work on Plesk 7.0.x

However, I do not remember if Plesk 7.0.x has the same 'websrvmng' command or not.
 
Yes, 7.0.x uses that same utility.

It seems to work ok for the main domain but not for the subdomains.

Thanks for the info on vhost being Apache and not Plesk - it narrows it down to maybe the utillity in 7.0 not working
for subdomains. Will have to check into if that utility is version specific.

Here's what is happening on my server with the 7.0.x
- create a subdomain via Plesk
- then create directory for the subdomain config at
/home/httpd/vhost/domain.com/subdomains/sub-dom/conf
- then create vhost.conf in that directory
- run websrvmng -u --vhost=domain.com
- then check in the domain's httpd.include and there is no line to include the vhost.conf within the virtualhost block for that subdomain

But it does work if I create a vhost.conf for the main domain.com
 
It should be /usr/local/psa/admin/bin/websrvmng -u --vhost-name=domain.com

If it still does not insert the Include line, then manually enter the Include line in the domain's httpd.include and restart Apache service.

The websrvmng utility may have had a bug in the 7.0x version.
 
Yes, I typed it brief in the post but yes that's how I have been issuing that utility on the command line.

It does work if I put it in manually - then whenever I update again though it will be overwritten and then I'll have to type it in again.

May have to end up trying to debug the websrvmng, if possible.
If I can do that successfully I'll post back the status.
 
Originally posted by jamesyeeoc It should be /usr/local/psa/admin/bin/websrvmng -u --vhost-name=domain.com

If it still does not insert the Include line, then manually enter the Include line in the domain's httpd.include and restart Apache service.

The websrvmng utility may have had a bug in the 7.0x version.

I don't think it's a bug - I actually think that vhost.conf and vhost_ssl.conf wasen't implemented on subdomain level in the 7.0.x versions...

The trick might be - to do the info about the subdomain in the vhost.conf for the domain (I think).
 
Also Power Toys have this implemente in VHOST.CONF as a template (just not on all system work :-( ))
 
Back
Top