Where is php executable linux?
I have installed Apache and PHP. I know PHP works as I have tested a simple PHP file on an Apache server. Show I'm writing a simple webserver which should be able to process PHP files. So once I get a request for a PHP file, I want to do something like 'exec php test.php' and get the output and pass it to the client. As I'm not much into Ubuntu, I don't know where the PHP executable is (should be in \bin right?) to do it. But there is no PHP file inside \bin or \usr\bin. When I run 'which php' it shows nothing. How do I do this? The default executable can be found with:
which, on my system, results in
This, in turn, is (on my system) a symbolic link to
And this is the actual executable:
After you install PHP or LAMP on a Linux server ( or XAMP on a Windows Server ), if you want to run command php in a terminal to execute a .php script file, you should first find the PHP install path and add the php executable file path in system environment variable PATH‘s value. But if there are multiple PHP version installed on the server, you should find the PHP version and related PHP install path which you need, and then you can run it accordingly. For example, you can invoke your required PHP version executable file on the Linux Cron job. This article will tell you how to check current PHP version and PHP install path in both Linux and Windows. It will also tell you how to change current PHP version to another one by edit the system environment variable PATH‘s value. 1. Check PHP Install Path On Linux.The $ whereis php php: /usr/bin/php $ $ ls -l /usr/bin/php lrwxrwxrwx. 1 root root 26 Dec 21 09:08 /usr/bin/php -> /www/server/php/73/bin/php If $ whereis php php: /usr/bin/php /usr/local/bin/php /usr/local/lib/php.ini $ $ which php /usr/local/bin/php 2. Check PHP Install Path On Windows.It is very easy for you to check PHP install path on Windows, because install PHP on Windows is just download the PHP zip file and unzip it to a local folder, then you can run it in a dos window like below. In below example, the php install path is C:\xampp\php\. C:\WorkSpace>C:\xampp\php\php -v PHP 8.0.0 (cli) (built: Nov 24 2020 22:02:57) ( ZTS Visual C++ 2019 x64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies If you want to run above example just by input command php -v, then you need to add the PHP install path ( C:\xampp\php\ ) in Windows system environment variable PATH‘s value. You can read article How To Set Windows Environment Variables. # First make sure php install path has been added in windows environment variable PATH's value. C:\WorkSpace>echo %PATH% ..........;C:\xampp\php # Now you can run command php in command console. C:\WorkSpace>php -v PHP 8.0.0 (cli) (built: Nov 24 2020 22:02:57) ( ZTS Visual C++ 2019 x64 ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies 3. Check Current PHP Version.Run # php -v PHP 7.9.9. (cli) (built: Dec 21 2020 09:06:30) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.25, Copyright (c) 1998-2018 Zend Technologies 3. Use phpinfo() Function To Get PHP Version & PHP Install Path.
Reference
Where is the PHP executable in Linux?From below example, we can see the PHP executable file path is /usr/bin/php , and it is linked to /www/server/php/73/bin/php file ( this is the real PHP executable file ). If whereis command returns multiple PHP install path, then you can run which command to get current PHP executable file path.
Where is my PHP installed?On Windows the default path for the php. ini file is the Windows directory. If you're using the Apache webserver, php. ini is first searched in the Apaches install directory, e.g. c:\program files\apache group\apache .
Where is PHP file in Ubuntu?The default location for the php. ini file is: Ubuntu 16.04: /etc/php/7.0/apache2.
How do I open a php file in Linux browser?You just follow the steps to run PHP program using command line.. Open terminal or command line window.. Goto the specified folder or directory where php files are present.. Then we can run php code using the following command: php file_name.php.. |