W3docs

How to check the presence of php and apache on ubuntu server through ssh

To check if PHP is installed on your Ubuntu system, you can use the following command:

To check if PHP is installed on your Ubuntu system, you can use the following command:

Example of checking the presence of php and apache on ubuntu server through ssh

php -v

This will display the version of PHP that is installed on the system. If PHP is not installed, the command will return a command not found error.

To check if Apache is installed on your Ubuntu system, you can use the following command:

apache2 -v

This will display the version of Apache that is installed on the system. If Apache is not installed, the command will return a command not found error.

You can also use the following command to check if Apache is running on your system:

systemctl status apache2

This will show the status of the Apache service and indicate whether it is running or not. If the service is running, it will also show the PID (process ID) of the Apache process. Note that you may need to use sudo for service management commands, as some operations require elevated privileges.

Note that these commands should be run on the command line via an SSH connection to the Ubuntu server.