Current Location: Home> Latest Articles> How to Check if PHP is Running on Linux

How to Check if PHP is Running on Linux

gitbox 2025-07-26

How to Check if PHP is Running on Linux

On a Linux system, ensuring PHP is running properly is a critical task for developers and system administrators. As PHP plays a vital role in building dynamic websites and applications, keeping it active ensures the stability of your web environment. This article outlines several reliable ways to check whether PHP is up and running on your Linux server.

Check PHP Processes

The most straightforward method is to use the terminal to look for PHP-related processes. Run the following command:

ps aux | grep php

This will list all active processes associated with PHP. If you see multiple PHP-related entries, that means PHP is currently running. If there’s no output, PHP might need to be started manually.

Check PHP-FPM Service Status

If your setup uses PHP-FPM (FastCGI Process Manager), you can check its status using the systemctl command:

systemctl status php7.x-fpm

Replace “7.x” with the actual version of PHP installed on your server. For example:

systemctl status php7.4-fpm

If the output includes “active (running)”, the PHP-FPM service is running correctly. If it is not active, you can start it using this command:

systemctl start php7.x-fpm

Use phpinfo() to Confirm PHP Setup

Another effective way to confirm PHP is working is to use the phpinfo() function. Create a file named info.php with the following content:

<?php
phpinfo();
?>

Place this file in your web server’s root directory and access it via a browser, e.g., http://localhost/info.php. If PHP is running, it will display a detailed page of configuration info. If not, double-check your web server settings.

Test PHP Response Using curl

To further verify PHP’s ability to handle requests, use the curl command:

curl -I http://localhost/info.php

If you receive an HTTP response, PHP is working as expected. If there’s an error, check your web server configuration or verify that PHP-FPM is properly connected to the server.

Conclusion

These methods allow you to quickly determine whether PHP is running on your Linux server. Regularly checking your PHP service helps maintain a reliable and stable web environment. Mastering these commands will enable you to troubleshoot and manage your server with confidence.