简体   繁体   English

PHP /服务器:我使用什么架构?

[英]PHP/Server: What architecture do I use?

How could I find out if I use a 64bit server or a 32bit server? 如何确定我使用的是64位服务器还是32位服务器? And how the installed PHP is built (in 32 or 64 bit mode)? 以及如何构建已安装的PHP(以32位或64位模式)?

I get for example the following server information with uname : 例如,我得到带有uname的以下服务器信息:

Linux #1 (here are some unnecessary information) x86_64

file cmd should give you an answer, I tried on ox-s and Centos 6.3 - see output below. 文件cmd应该给您一个答案,我在ox-s和Centos 6.3上尝试过-请参见下面的输出。 Pretty clear: 很清楚:

os-x: $ file /usr/local/zend/bin/php /usr/local/zend/bin/php: Mach-O executable i386 os-x:$文件/ usr / local / zend / bin / php / usr / local / zend / bin / php:Mach-O可执行文件i386

CentOS: $ file /usr/bin/php-cgi /usr/bin/php-cgi: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped CentOS:$ file / usr / bin / php-cgi / usr / bin / php-cgi:用于GNU / Linux的ELF 64位LSB可执行文件,x86-64版本1(SYSV),动态链接(使用共享库) 2.6.18,剥离

x86_64 would only show up if you're running a 64bit kernel. 仅当您运行64位内核时,才会显示x86_64。 Otherwise it'd be one of the older/32bit architectures, like 386 or 686. As for PHP, if you're running the version that came with your distro, it should be compiled for the same architecture as the rest of the system, in other words, on a 64bit Linux distro, you should have a 64bit PHP by default. 否则,它将是较旧的/ 32位体系结构之一,例如386或686。对于PHP,如果您正在运行发行版随附的版本,则应针对与系统其余部分相同的体系结构进行编译,换句话说,在64位Linux发行版上,默认情况下应具有64位PHP。

For a Debian-based system, you can query the package for info: 对于基于Debian的系统,您可以查询软件包以获取信息:

dpkg -p php5-cli

which returns 哪个返回

[...snip...]
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: php5
[...snip...]

eg this version of PHP is a 64bit compile. 例如,此版本的PHP是64位编译器。

Well, x86_64 means it's a 64-bit build. 好吧, x86_64表示它是64位版本。

My uname -a ( -a displays all info) is: 我的uname -a-a显示所有信息)是:

Linux [can't see this] 2.6.35-23-generic #41-Ubuntu SMP Wed Nov 24 11:55:36 UTC 2010 x86_64 GNU/Linux , so I know I'm on a 64 bit system. Linux [can't see this] 2.6.35-23-generic #41-Ubuntu SMP Wed Nov 24 11:55:36 UTC 2010 x86_64 GNU/Linux ,所以我知道我使用的是64位系统。

To test PHP's build, I would look at the output of this command: 为了测试PHP的构建,我将查看以下命令的输出:

php -r "echo phpinfo();"

It spits out tons of HTML, so if you want, pipe it to a file and then view it with a browser: 它会吐出大量HTML,因此,如果需要,可以将其通过管道传输到文件中,然后使用浏览器进行查看:

php -r "echo phpinfo();" > PHPinfo.html

I looked through mine, and it didn't say much about the version or architecture. 我浏览了我的,并没有对版本或体系结构说太多。

Next, let's see what php -v says. 接下来,让我们看看php -v的含义。 Mine spits out: 矿井喷出:

PHP 5.3.3-1ubuntu9.1 with Suhosin-Patch (cli) (built: Oct 15 2010 14:00:18) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbH

Still nothing. 依然没有。 Let's probe Debian's clockworks: 让我们探究Debian的发条:

If you are running a Debian spinoff, run: 如果您正在运行Debian衍生产品,请运行:

dpkg -p php5-cli | grep "Architecture"

It should tell you PHP's build architecture. 它应该告诉您PHP的构建体系结构。 Mine says: 我的说:

Architecture: amd64

This confirms that PHP is 64 bit. 这确认PHP是64位。

Good luck! 祝好运!


Just to make it more compatible, if you can't run dpkg , never fear; 只是为了使其更加兼容,如果您无法运行dpkg ,请不要担心; file is here! file在这里!

Run file {press key to the left of 1}which php5{press key to the left of 1} to tell you the binary information. 运行file {press key to the left of 1}which php5{press key to the left of 1}告诉您二进制信息。

I get: 我得到:

/usr/bin/php5: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, from 'o', stripped

This confirms I am running 64-bit PHP. 这确认我正在运行64位PHP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM