Link to home
Start Free TrialLog in
Avatar of galiganu
galiganuFlag for Canada

asked on

How to find out PHP, APACHE and MySQL install directories from a php script?

Hi,

I need to find out PHP, APACHE and MySQL install directories from a php script.
It is possible?

Thanks,
gali
Avatar of ixti
ixti
Flag of Spain image

There's no built-in functions to do it.
You can use exec() or passthru() to call your external program which can do it.
But you have to write a program that can do it before...
Avatar of galiganu

ASKER

Just to be more clear: I need to find the paths to php, apachectl and mysqld executables.
Also to MySQL databases location.

Thanks again,
gali
thanks ixti

what this program should do? search the entire hard drive for this executables?
ASKER CERTIFIED SOLUTION
Avatar of ixti
ixti
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Conceited,
for example, I don't have any of paths related with Apache, MySQL and PHP in my PATH enviroment... But this is one the easier solution anyway (if this enviroment is set).
Avatar of Conceited
Conceited

Well the $_SERVER var should be accessible it also contain path related info

imo ixti's solution is time exausting
I totally agree that my solution is VERY exhausting. But:

1. Superglobal arrays may not have necessary data for Conceited solution.

2. There's no way to do this in simple and beautiful way. There's no built-in functions. So even if everythin what you need will be present in enviroment or server variables, even in this case you'll got to open, then parse config files...

3. You can do <?php $a = array(); exec('dir c:\php.exe /S', $a); ?> and then extract data you need. Or simply make a lightweight program that do the same as "dir C:\php.exe /S" but returns only paths, so you can grab them to array and do what you want.