Reputation: 8360
How could I find out if I use a 64bit server or a 32bit server? And how the installed PHP is built (in 32 or 64 bit mode)?
I get for example the following server information with uname
:
Linux #1 (here are some unnecessary information) x86_64
Upvotes: 1
Views: 2856
Reputation: 883
file cmd should give you an answer, I tried on ox-s and Centos 6.3 - see output below. Pretty clear:
os-x: $ file /usr/local/zend/bin/php /usr/local/zend/bin/php: Mach-O executable 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
Upvotes: 3
Reputation: 298066
Well, x86_64
means it's a 64-bit build.
My uname -a
(-a
displays all info) is:
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.
To test PHP's build, I would look at the output of this command:
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:
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. 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:
If you are running a Debian spinoff, run:
dpkg -p php5-cli | grep "Architecture"
It should tell you PHP's build architecture. Mine says:
Architecture: amd64
This confirms that PHP is 64 bit.
Good luck!
Just to make it more compatible, if you can't run dpkg
, never fear; file
is here!
Run file {press key to the left of 1}which php5{press key to the left of 1}
to tell you the binary information.
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.
Upvotes: 1
Reputation: 360572
x86_64 would only show up if you're running a 64bit kernel. 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.
For a Debian-based system, you can query the package for info:
dpkg -p php5-cli
which returns
[...snip...]
Maintainer: Ubuntu Core Developers <[email protected]>
Architecture: amd64
Source: php5
[...snip...]
e.g. this version of PHP is a 64bit compile.
Upvotes: 1