Check Apache version by PHP

Beside use command to check the version, you can use the php script to check the php version. Why that so? So application do need to verify by php first before allow you to install the apps.

<?php

$ar = split("[/ ]",$_SERVER['SERVER_SOFTWARE']);
for ($i=0;$i<(count($ar));$i++)
{
switch(strtoupper($ar[$i]))
{
case 'APACHE':
$i++;
$Apache_Version = $ar[$i];
break;
case 'PHP':
$i++;
$PHP_Version = $ar[$i];
break;
case 'MOD_SSL':
$i++;
$MOD_SSL_Version = $ar[$i];
break;
case 'OPENSSL':
$i++;
$OPENSSL_Version = $ar[$i];
break;
}
}

Echo "Apache Version: $Apache_Version<br>\n";
Echo "PHP Version: $PHP_Version<br>\n";
Echo "mod_ssl Version: $MOD_SSL_Version<br>\n";
Echo "OpenSSL Version: $OPENSSL_Version<br>\n";

?>

PHP-MySQL connection string

Using the Host

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

Using Hostname

<?php
// we connect to example.com and port 3307
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

// we connect to localhost at port 3307
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

Using Socket Path

<?php
// we connect to localhost and socket e.g. /tmp/mysql.sock

// variant 1: omit localhost
$link = mysql_connect(':/tmp/mysql', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

// variant 2: with localhost
$link = mysql_connect('localhost:/tmp/mysql.sock', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

How to Test IMAP is working?

Beside using the telnet, you can use php script as below as well.

<?
$mbox = imap_open(“{mail.loacalhost:143/novalidate-cert}INBOX”, “emailaddress”, “password”);
print_r(imap_errors());
?>

Note:
emailaddress is the email address that need to test
password is the email address password