Home > Article > Operation and Maintenance > What is the reason why linux cannot query the php process?
Stop or crash
One possibility is that the PHP process has stopped or crashed. If there is no appropriate script set up to regularly detect this situation, we can only obtain relevant information by viewing the log (usually located under /var/log/httpd/ or /var/log/nginx/). If no obvious error message is found, we can also try to check whether there is a PHP process running through the following command:
ps aux | grep php
This command will output all currently running PHP processes. If there is no output, it means that there is no running PHP process on the system.
Memory limit
If there is a large PHP application in our system, we may encounter the PHP process reaching the memory limit, causing the process to be killed. Condition. To solve this problem, we need to increase the memory limit by modifying the PHP configuration file:
memory_limit = 256M
This will set the memory limit to 256MB. Of course, if the server space is relatively rich, you can also modify this value to be higher.
PHP version issue
We also need to pay attention to the PHP version issue. Some servers may have multiple versions of PHP installed at the same time, but only one of them is running. Therefore, we must confirm the currently running PHP version, which can be viewed through the following command:
php -v
If the currently running PHP version does not match the version we expect, we can use the following command to change the current PHP version:
sudo a2dismod php7.1 sudo a2enmod php7.2 sudo service apache2 restart
The above command will uninstall version 7.1 of PHP, enable version 7.2 of PHP, and finally restart Apache.
PHP extension issues
Another common problem is that a PHP application requires certain PHP extensions but the system does not have them installed. In this case, we can install the missing extension through the following command:
sudo apt-get install php7.x-common php7.x-curl php7.x-gd php7.x-json php7.x-mbstring php7.x-mysql php7.x-xml php7.x-zip
You need to modify the x in the above command to the current PHP version. This command will install common PHP extensions required to run PHP applications. Remember to restart the web server after installation.
The above is the detailed content of What is the reason why linux cannot query the php process?. For more information, please follow other related articles on the PHP Chinese website!