Koozali.org: home of the SME Server
Legacy Forums => Experienced User Forum => Topic started by: Garfield on August 09, 2004, 08:56:55 PM
-
Hi,
I am preparing a migration from my Win2k03 server to an SME server (finally !).
I am hosting several websites which rely on the use of PHP / MySQL. For various database connections, I have created several PHP includes containing the passwords. On my Windows server they are all located in c:\php\includes and this path in my php.ini file.
I want to create a similar solution on my SME box, but so far I have not succeeded. I have searched the manuals, this site and the Internet but have not found an answer.
What I found so far is a php.ini file in /etc.
In this file it says that the include path is ".:/usr/share/php". So I thought I'd put the include files in /usr/share/php (Any directory OUTSIDE of my websites is fine by me). In /usr/share was no directory php, so I created one (as root) and put all my includes there. This didn't work. As errors I get connections refused, saying "access denied for user www@localhost".
I have not chown'd this directory and files, could it be as simple as that ?
So, obviously there is more to it.
Who can help me with this ?
Any help is greatly appreciated !
Best Regards,
Arvid
-
Hi,
not really sure, but try a search on 'open_basedir'.
RequestedDeletion
-
Hi,
Thanks for your reply, but it didn't solve the problem. I did the search and came up with some posts about expanding PHP templates (http://forums.contribs.org/index.php?topic=23101.0).
In that post I found that the default php.ini fragment handling the include path for an SME server is located in:
/etc/e-smith/templates/etc/php.ini/50PathsDirectories
When I cat this file, it reads that the include path is: ".:/usr/share/php", thus the path I had found already in /etc/php.ini.
And as I said, creating a directory php under /usr/share and putting my includes there didn't work.
So I am still puzzled and would greatly appreciate further help with this matter.
-
As a side note, when I put my includes in the html directory of a website, say /home/e-smith/files/ibays/Primary/html, all is working well.
Changing owner & group for the directory php under /usr/share and the files in /usr/share/php to admin / shared doesn't work.
-
I also think you should look at open_basedir, - if I understand your question correctly.
From the primary site, - or any other Ibay, - you can only access files 'inside' the Ibay.
If you look into /etc/httpd/conf/httpd.conf you can see the open_basedir restrictions in the bottom.
You can access all files 'below' the open_basedir which is why it works when you put your include files in the html folder.
Changing the open_basedir to /home/e-smith/files/ibays would give you access to another Ibay if that could do something for you, - or even / if you need access to /etc
The above is an issue when say trying to access a common statistics module from several ibays, - maybe it apply's aswell to your php include file problem.
Changing the open_basedir could be done like this :
/sbin/e-smith/db accounts setprop Primary PHPBaseDir /
/sbin/e-smith/signal-event ibay-modify Primary
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
Kim Igel
P.s. do a backup before you do anything. I didn't :-) and now I'm having trouble with exactly this.. I did change the open_basedir for my primary site, - giving access to another Ibay, - but it run's very slow now (the include-part's of my statistics module), - and though I changed the open_basedir back it still runs slowly (accessing file only in my local html folder)... not including the statistics makes it go fast again.... just be carefull.. :-)
-
Hi,
Thanks for your input.
My need is that I want to have my includes (which contain db passwords) out of the directories under any website tree. In SME-terms: outside of any html directory.
Thus moving the includes to the next higher level, in this case /home/e-smith/files/ibays/Primary would do the trick.
Because in /etc/httpd/conf/httpd.conf the open_basedir is set to /home/e-smith/files/ibays/Primary, I have no need to modify this, should it work.
I moved my includes to /home/e-smith/files/ibays/Primary, but that didn't yield the desired result.
Furthermore, It seems that the includes have to be in the same directory as the php file needing the include file.
Thus for a file /home/e-smith/files/ibays/Primary/html/dummydir/action.php
the include must be in /home/e-smith/files/ibays/Primary/html/dummydir.
It does not work when it is in /home/e-smith/files/ibays/Primary/html.
I'm still puzzled ....
-
Got it !
Now that I know how to do it, it proves fairly easy (as always).
So here's my little HowTo:
Problem: Use PHP includes outside of any website directory tree.
Solution: Create suitable directory to hold includes and modify Apache httpd configuration.
1. Create directory php under /usr/share
2. Chown admin php, chgrp shared php
3. Put includes in /usr/share/php
4. cp /etc/e-smith/templates/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/95AddType00PHP2ibays
5. Change the line reading "php_admin_value open_basedir $basedir\n"; to "php_admin_value open_basedir $basedir:/usr/share/php\n";
6. /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
7. apachectl restart
DONE !
Notes:
- I have not tested if the includes work with root as owner and group,
- I have only tested this for the Primary website, over the next few days I will test whether this also works for other ibays
- All this was done on SME 6