In Linux systems, PHP path query is very important. When you need to use various functions of PHP, you need to know the path to PHP. In this article, we will explore how to do PHP path query under Linux.
which command can be used to find the location of a specified command, including PHP. Enter the following command in the terminal to find the path of PHP:
which php
After pressing the Enter key, the terminal will output the absolute path of PHP.
The whereis command can be used to find the location of a specified file, including PHP. Enter the following command in the terminal to find the path of PHP:
whereis php
After pressing the Enter key, the terminal will output the path of PHP.
The find command can search for files and directories in the file system. Enter the following command in the terminal to search the path of PHP:
sudo find / -name php
If you know the directory where PHP is installed, you can specify the directory when searching, which can reduce search time. For example, find PHP in the /usr/local directory:
sudo find /usr/local -name php
If PHP has set the path in the environment variable, then you can use the following Command view:
echo $PATH
This command will display all paths in the environment variable PATH. If the PHP path is set, it will be in it.
Under Linux, PHP configuration files are usually located in the /etc/php directory. If you don’t know the specific path of PHP installation, you can view the configuration in the following file:
/etc/php.ini
You can use the following command to view the file:
cat /etc/php.ini
In this configuration file, you can view PHP The path to the installation.
Summary
It is very important to perform PHP path query in Linux system. This article covers several common methods, including using the which, whereis, and find commands, as well as viewing environment variables and PHP configuration files. These methods can effectively locate the PHP path and help you use PHP better.
The above is the detailed content of How to query php path under linux. For more information, please follow other related articles on the PHP Chinese website!