PHP code to get PHP, MySQL and Apache version information

Source: Internet
Author: User
Tags mysql version php file phpinfo

Sometimes we install or develop Php+mysql+apache applications that require a version of the environment, and we can use the following code to query PHP, MYSQL, and Apache versions of the information to see if they meet our needs.

1. Direct access to PHP version

<?php
Echo ' PHP version: '. Phpversion ();
?>

2. Get MySQL version directly

<?php
mysql_connect (' 127.0.0.1 ', ' root ', ');
Echo ' MySQL version: '. Mysql_get_server_info ();
?>

3. Get Apache Version

<?php
Echo ' Apache version: '. Apache_get_version ();
?>

If we want to query more detailed PHP configuration, we can use the following sentence code directly:

<?php
Phpinfo ();
?>


Linux,apache,php,mysql Common way to view version information

1. View Linux kernel version , System information, commonly used in three ways:

Uname-a; More/etc/issue; Cat/proc/version;


2. View Apache version information , if it is through Yum, or RPM installed, you can use Rpm-qa |gerp httpd to view;


Can also be queried by httpd-v;


Of course, after the installation of Apache, you can directly elink the loop to view Apache information.

3. View PHP Version Information , if it is through Yum, or RPM package installed, you can use Rpm-qa |grep php to view;


Also, you can use Php-v to view the version information of PHP;


Generally, after installing lamp, use Phpinfo's test page to view the installed PHP information;

The concrete method is to/var/www/under the new index.php file, the concrete content namely

PHP phpinfo ();

?>

Can. You can then add the index.php type to the/etc/httpd/conf/httpd.conf file and restart the httpd to get the following results.


4. View MySQL version information , if it is installed through the Yum, or RPM package installed, you can use Rpm-qa |grep mysql to view;


You can also use Mysql-v or--help|grep distrib to view it.


You can also access MySQL, and then select Version () by command, to view;


or the Status command view.


Personally think these are more commonly used methods, of course, there will certainly be more effective, more convenient ways and means.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.