How to check my PHP and MySQL version on Ubuntu VPS?

Solution 1:

Do it from your command line:

php -v
mysql -V

and:

php -i | grep -i '^libxml'

OR

Put this in your root directory:

 <?php
    phpinfo();
 php?>

Save it as phpinfo.php and point your browser to it (this could be http://localhost/phpinfo.php)

Solution 2:

Use dpkg to find the installed package versions.

dpkg -l | grep '\(php\|mysql\)'

Solution 3:

Any one of these queries will tell you what the MySQL version running is once connected:

SELECT VERSION();

SHOW VARIABLES LIKE 'version';

This works for MySQL 5.1+

SELECT variable_value FROM information_schema.global_variables
WHERE variable_name='version';

Doing the following from the command line:

mysql -V will get you the version of the client.

mysqld -V will get you the version of the server.