如何创建phpinfo页面?

PHP is very popular programming language used by a lot of programmers and web devleopers. During PHP application development we may need to get detailed information about the platform the PHP web server runs. This type of information is provided by phpinfo function. phpinfo() function provides information like PATH, User, Operating System, Modules etc.

PHP是许多程序员和Web开发人员所使用的非常流行的编程语言。 在PHP应用程序开发过程中,我们可能需要获取有关PHP Web服务器运行平台的详细信息。 此类信息由phpinfo函数提供。 phpinfo()函数提供诸如PATH,用户,操作系统,模块等信息。

安装PHP (Install PHP)

We will use php command PHP Framework in this tutorial. So we need to install it properly before starting. We can install PHP like below.

在本教程中,我们将使用php命令PHP Framework。 因此,我们需要在开始之前正确安装它。 我们可以像下面那样安装PHP。

Ubuntu,Debian,Mint,Kali: (Ubuntu, Debian, Mint, Kali:)

$ sudo apt install php

Fedora,CentOSi RHEL: (Fedora, CentOSi RHEL:)

$ sudo yum install php

创建phpinfo.php页面 (Create phpinfo.php Page)

We will start by creating a phpinfo web page. Actually it is very easy to create one. We just use following PHP code to list phpinfo.

我们将从创建一个phpinfo网页开始。 实际上创建一个很容易。 我们只使用以下PHP代码列出phpinfo。

<?php 

phpinfo(); 

?>

在Apache Web服务器上运行phpinfo (Run phpinfo On Apache Web Server)

As we know PHP is a dynamic server side language. We need to run PHP code on the server with PHP framework and Web Server Application which is Apache in this case. Put the code described above into the the path /var/www/html

众所周知,PHP是一种动态的服务器端语言。 我们需要在具有PHP框架和Web服务器应用程序(在本例中为Apache)的服务器上运行PHP代码。 将上述代码放入路径/var/www/html

$ cp phpinfo.php /var/www/html

and run following command to start Apache Web Server. But we need to be sure that PHP modules are installed properly.

并运行以下命令以启动Apache Web Server。 但是我们需要确保正确安装了PHP模块。

$ sudo systemctl start apache2

Or

要么

$ sudo systemctl start httpd

在命令行上运行phpinfo (Run phpinfo On Command Line)

If we need to run phpinfo in a more secure and local way we can use command line option which will put the output of the phpinfo page into terminal.

如果我们需要以更安全和本地的方式运行phpinfo ,可以使用命令行选项,它将phpinfo页面的输出放入终端。

$ php7.2 phpinfo.php

OR

要么

$ php phpinfo.php
Run phpinfo On Command Line
Run phpinfo On Command Line
在命令行上运行phpinfo

使用PHP Web服务器从命令行运行phpinfo (Run phpinfo On From Commmand Line with Php Web Server)

We can also create a temporary web server which will serve the phpinfo web page. We will use again the php command. We will also provide the IP address and port number we want to run web server.

我们还可以创建一个临时的Web服务器,该服务器将为phpinfo网页提供服务。 我们将再次使用php命令。 我们还将提供我们要运行Web服务器的IP地址和端口号。

$ php7.2 -S 0.0.0.0:8080 phpinfo.php
Run phpinfo On From Commmand Line with Php Web Server
Run phpinfo On From Commmand Line with Php Web Server
使用PHP Web服务器从命令行运行phpinfo
Run phpinfo On From Commmand Line with Php Web Server
Run phpinfo On From Commmand Line with Php Web Server
使用PHP Web服务器从命令行运行phpinfo

WordPress phpinfo插件 (WordPress phpinfo Plugin)

If we are running a CMS (Content Management System) like WordPress we have options which is more practical then creating a web page and serve it. WordPress provides the PHPINFO plugin from the following link.

如果我们运行的是像WordPress这样的CMS(内容管理系统),那么我们有一些更实用的选项,然后创建一个网页并提供服务。 WordPress通过以下链接提供了PHPINFO插件。

LEARN MORE  What Is Computer Programming?
了解更多什么是计算机编程?

https://wordpress.org/plugins/wordpress-php-info/

https://wordpress.org/plugins/wordpress-php-info/

翻译自: https://www.poftut.com/how-to-create-phpinfo-pages/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值