PHP code to obtain PHP, MySQL, and Apache version information-PHP source code

Source: Internet
Author: User
This article describes the simplest code to use php to obtain information about PHP, MySQL, and Apache versions. It can be done with only one sentence of code, which is very practical. This article describes the simplest code to use php to obtain information about PHP, MySQL, and Apache versions. It can be done with only one sentence of code, which is very practical.

Script ec (2); script

Sometimes the PHP + MYSQL + Apache application we install or develop requires the Environment version, at this time, we can use the following code to query the PHP, MySQL, and Apache version information to see if it meets our needs.

1. directly obtain the PHP version

Echo 'php version: '. phpversion ();
?>

2. Obtain the MySQL version directly.

Mysql_connect ('2017. 0.0.1 ', 'root ','');
Echo 'mysql version: '. mysql_get_server_info ();
?>

3. Obtain the Apache version

Echo 'apache version: '. apache_get_version ();
?>

To query more detailed PHP configurations, use the following code:

Phpinfo ();
?>


Common Methods for viewing version information in linux, apache, php, and mysql

1. view the linux kernel versionThere are three common methods for system information:

Uname-a; more/etc/issue; cat/proc/version;


2. View apache version informationIf it is installed through yum or rpm, you can use rpm-qa | gerp httpd to view it;


It can also be queried through httpd-v;


Of course, after installing apache, you can directly query apache information through the elink loop.

3. View php version informationIf the package is installed using yum or rpm, you can use rpm-qa | grep php to view the package;


You can also use php-v to view the php version information;


Generally, you can use the phpinfo test page after installing lamp to view the installed php information;

The specific method is to create the index. php file under/var/www/. The specific content is

Php phpinfo ();

?>

You can. Add the index. php type to the/etc/httpd/conf/httpd. conf file and restart httpd. the following result is displayed.


4. View mysql version informationIf it is installed through yum or rpm package, you can use rpm-qa | grep mysql to view it;


You can also use mysql-v or -- help | grep Distrib to view it;


You can also go to mysql and run select version;


Or status; command to view.


I personally think that these are commonly used methods. Of course, there will certainly be more effective and convenient methods and approaches.

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.