Hi!
How can I get PHP installation path on virtual private server?
Thanks in advance
Hi!
How can I get PHP installation path on virtual private server?
Thanks in advance
Type
which php
to the command line and press Enter
Try what does this show for you?
echo $_SERVER["PATH"];
Can I get something from ‘phpinfo’ through webpage?
What you mean? Do you want to grab it from phpinfo() function’s result?
Yes, may I get PHP path from this function.
What is the problem with this?
echo $_SERVER["PATH"];
Did you try the above? And why do you want to get it from phpinfo() function only? You are wanting only to know or you want to use it somewhere in your website?
Actually my client has linux based VPS of ‘1and1’ . I have access PLESK 8.1 controal panel with admin rights. On this VPS, there are multiple websites. There I didn’t find PHP installation path against some specific website.
If I write Cron in ‘root’ user, then this cron doesn’t run.
Thats all the scenario. If someone has better solution to run cron against specific domain, it will be highly appreciated.
NOTE: I noticed that, cron is running against specific domain but it is not able to find path of PHP to execute PHP script.
Thanks in advance
Well i had worked on plesk 8.1 before but that was my special dedicated server so as far as i can remember that there you don’t have to specify PHP installation path though to run the script file that is set from the cron.
Where have you planned to use that installation path by the way? Why do you need PHP installation path? AFAIK, Plesk should know the PHP path itself to run your cron script. But i dont know whether that differs for different domains but that will take the physical path of the script file and run.
Edit:
And if you have full access to the server then use PUTTY (SSH) and try to run the command which php and see where is your installation path.
Thanks for detailed reply:
In ‘root’ user scheduled task, Iam giving following cron command [this doesn’t run] :
Time :
0 * * * *
Command :
/usr/local/psa/admin/bin/php /srv/www/vhosts/*******/httpdocs/cron.php
Other cron tasks with ‘root’ user are running fine.
And in scheduled task of specific domain, I give following :
Time :
0 * * * *
Command :
php /srv/www/vhosts/*******/httpdocs/cron.php
Note : I also used ‘-q’ switch with php command.
#!/usr/local/psa/admin/bin/php or #!php [This command is written on top of php webpage which will run through cron]
Thanks in advance
Then are you sure /usr/local/psa/admin/bin/php is your PHP path? Try to see running “which php” in your SSH console and copy and paste the path. Or even that above code line $_SERVER[‘PATH’] should return the php installation path for you which you can use.
$_SERVER[‘PATH’] gives me following info. What will be the PHP path from following:
" /bin:/usr/bin:/sbin:/usr/sbin "
Thanks in advance
Ummm! that’s strange. I think for security purposes there is no such easier way to find the installation path. But try the something like the following if you are rally not able to find from SSH too.
/usr/local/php/bin/php
or
/usr/local/php5/bin/php
I don’t have linux server here to test all the things.
Edit:
Try this as well
echo "<pre>";
echo exec('whereis php');
echo "</pre>";
I really thanks for all of you who helped me in solving my cron problem.
One other confusion is there.
Iam including files in my cron file as follows:
/**********************************/
$fpath = $_SERVER[‘DOCUMENT_ROOT’];
include_once ($fpath.“/main/dbcon.php”);
The above is giving me following PHP WARNING :
PHP Warning: include_once(): Unable to access /main/dbcon.php …
But if I include as follows, then it works fine.
include_once (“/srv/www/vhosts/******/httpdocs/main/dbcon.php”);
Can anybody help or give suggestions about my current problem.
Thanks in advance