Follow these simple steps to find out the status of Apache HTTP web server, MySQL and PHP in your LAMP stack.
Apache HTTP web server
Go to http://server-ip:80 on your web browser. A page saying your Apache server is running properly should show up.
If it isn’t working, then check the status of the Apache web server by running the following command in your terminal
# service apache2 status
# /etc/init.d/httpd status
This command will show whether Apache is running or has stopped. If it is stopped, then restart the web server for which use the below command.
# service apache2 restart
# /etc/init.d/httpd restart
You can use mysqladmin command to find out whether mysql is running or not.
# mysqladmin -u root -p status
Enter password: Uptime: 232454 Threads: 1 Questions: 25 Slow queries: 0 Opens: 16 Flush tables: 1 Open tables: 9 Queries per second avg: 0.0
If mysql is not running, you will receive the following message or similar.
mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
You can restart mysql service using the following command
# sudo service mysql restart
# sudo service mysqld restart
After restarting mysql, you can check the status again to make sure it is running.
To verify if php is installed properly and running in your Virtual Compute Node, create a file by using the command below
sudo vim /var/www/html/info.php
Press the key I to edit the file, enter the following content in the file and then save and exit by pressing ESC key followed by :wq! then hit Enter.
<?php phpinfo(); ?>
Then restart the Apache web server . This is done in order for the web server to recognize the changes done to the server. You can check the status of php by entering the following URL in your web browser.
If php is running in your server, you will receive the following message in your web browser.