Is there a problem with my server?

Avatar
  • Answered
Ok ok, so after lots of testing... here's what I got:

1. my domain name is registered
2. it is pointing to your servers, and dns has not been updated in 6 months
3. the connection between my computer and your server is lightning fast

My website runs off of php, and it runs off of mysql. I'm on a shared server.

MY QUESTIONS ARE:
1. How can I tell if php is running on my server?
2. How can I tell if MySQL is running on my server?
3. Is there like a, "server health" page or something on the server that I can visit to ensure everything is AOK?

thank you thank you thank you thank you!
Avatar
JacobIMH
Hello, and thanks for your questions. Unfortunately as I don't have a way to determine what server you're hosted on with this question being submitted anonymously, I can't provide a direct answer to if there are any problems on it.

How to tell if PHP us running on server

If you're on a shared server and are curious if PHP is working, the easiest way to test this is to simply create a small PHP script and try to access it. For instance the following test.php code would work fine:
<?php
echo "test";
?>

How to tell if MySQL is running on server

To tell if MySQL is also running, you could connect to MySQL from a simple PHP script like:
<?php

$hostname = "localhost";
$db_Name = "userna5_db";
$db_User = "userna5_user";
$db_Pass = "g00dpaSS";

//Connect to MySQL
$con = mysql_connect($hostname, $db_User, $db_Pass);

// Display error if connection to MySQL server fails
if (!$con){
        die('MySQL server error: ' . mysql_error());
}

//Select database
$selectDB = mysql_select_db($db_Name, $con);

// Display error if selecting the database fails
if (!$selectDB){
        die('MySQL database error: ' . mysql_error());
}

?>

Viewing the server health

Unfortunately on a shared server there isn't a server health dashboard that you can view. You could run a cron job which is just a scheduled task to query the server once a day if you were curious about historical usage. For instance if you created this file called LOAD_CHECK in your home directory /home/userna5/:
#!/bin/bash
// Get number of processors on server
CPU_COUNT=$(grep processor /proc/cpuinfo -c)

// Log the date, and times server has spiked over the number of processors
date > ~/LOAD_LOG
sar -q | awk -v CPUs=$CPU_COUNT '{ if ($5>=CPUs) print $0}' >> ~/LOAD_LOG
You could then create a cronjob to call that script once everyday at 11:45PM which would look like this:
45	23	*	*	*	bash /home/userna5/LOAD_CHECK
Then what that script does is create a LOAD_LOG file in your home directory. Which the output would look something like:
Fri Oct  4 16:13:01 EDT 2013
00:00:01      runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
11:46:01           10      4418     25.53     18.13     13.31
11:48:01           12      4444     16.26     16.64     13.32
In this case, it would show that there were 2 minutes today in which the server had spiked over its optimal load of 16 based on how many processors the server has. If you saw a whole lot of these types of entries, than that could indicate problems on the server during those time periods. I hope that information was helpful, if you had any further questions at all please let us know. - Jacob