Difference between revisions of "PHP"

From CBLFS
Jump to navigationJump to search
(Configuration Information)
(32Bit: Fixed a bit of dubious wording)
 
(42 intermediate revisions by 13 users not shown)
Line 2: Line 2:
 
|-
 
|-
 
!Download Source:
 
!Download Source:
| http://www.php.net/get/php-5.2.1.tar.bz2/from/this/mirror
+
| http://us2.php.net/get/php-{{PHP-Version}}.tar.bz2/from/us.php.net/mirror
 
|}
 
|}
  
 
----
 
----
  
== Introductin to PHP ==
+
{{Package-Introduction|PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.|http://www.php.net/}}
 
 
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
 
  
 
== Warning: ==
 
== Warning: ==
Line 24: Line 22:
 
=== Optional ===
 
=== Optional ===
 
* [[libjpeg]]
 
* [[libjpeg]]
 +
* [[libmcrypt]]
 
* [[GDBM]]
 
* [[GDBM]]
 
* [[OpenSSL]]
 
* [[OpenSSL]]
 
* [[OpenLDAP]]
 
* [[OpenLDAP]]
 
* [[MySQL]]
 
* [[MySQL]]
 +
* [[GD]]
  
 
== Configuration Information ==
 
== Configuration Information ==
Line 34: Line 34:
  
 
If you use Apache 1 then you must use --with-apxs instead --with-apxs2
 
If you use Apache 1 then you must use --with-apxs instead --with-apxs2
 +
 +
If you want use Libmcrypt then you must add --with-mcrypt to the configure script
 +
 +
 +
{{Note|PHP does not use ''DESTDIR'', it uses ''INSTALL_ROOT'' for the same purpose.  Use ''INSTALL_ROOT'' as you would normally use ''DESTDIR''. There are some errors that are safe to ignore. It also will fail if it does not find a valid httpd.conf in the < DIRECTORY >etc/apache folder. one way to fix this is
 +
install -d <DIRECTORY>/etc/apache
 +
&& cp /etc/apache/httpd.conf <DIRECTOR>/etc/apache/
 +
or figure out a way to fake the httpd.conf. remember to deal with the new data in httpd.conf with your installer}}
 +
 +
{{Note|There are some reproducable problems with PHP on both x86 and x86_64 architecture when compiling with GCC4 and '''-O3''' optimization (see for example <nowiki>http://bugs.gentoo.org/show_bug.cgi?id=211611</nowiki>, there are more).}}
  
 
== Non-Multilib ==
 
== Non-Multilib ==
Line 41: Line 51:
 
  ./configure --prefix=/usr --sysconfdir=/etc/php \
 
  ./configure --prefix=/usr --sysconfdir=/etc/php \
 
     --libdir=/usr/lib --localstatedir=/var \
 
     --libdir=/usr/lib --localstatedir=/var \
     --with-apxs2=/usr/sbin/apxs --with-mysql &&
+
     --with-apxs2=/usr/sbin/apxs --with-mysql \
 +
    --with-layout=GNU &&
 
  make
 
  make
  
Line 47: Line 58:
  
 
  make install
 
  make install
  cp php.ini-recommended /etc/php/php.ini
+
  cp php.ini-production /etc/php/php.ini
  
The installscript change your Apache config and add the entry: "LoadModule php4_module   lib/apache/libphp4.so"
+
The install script changes your Apache configuration and adds the entry: "LoadModule php{{PHP-Version2}}_module   lib/apache/libphp{{PHP-Version2}}.so"But it forgets to set the mime application type. Open /etc/apache/httpd.conf and add following line in the <IfModule mime_module> section:
But it forgets to set the mime applicationtype. So go to the /etc/apache/httpd.conf and add fowlling line under
 
<IfModule mime_module>:
 
  
 
  AddType application/x-httpd-php .php .phtml .php3 .htm .html
 
  AddType application/x-httpd-php .php .phtml .php3 .htm .html
 +
 +
When you want start a site with php-code, you must add:
 +
 +
<IfModule dir_module>
 +
    DirectoryIndex index.html index.php index.php3 index.htm
 +
</IfModule>
 +
 +
To test your PHP installation, try this:
 +
 +
cat > /srv/www/htdocs/phptest.php << "EOF"
 +
<html>
 +
<head>
 +
<title>PHP-Testpage</title>
 +
</head>
 +
<body>
 +
<?php
 +
phpinfo();
 +
?>
 +
</body>
 +
</html>
 +
EOF
 +
 +
/etc/rc.d/init.d/apache restart
 +
lynx localhost/phptest.php
  
 
== Multilib ==
 
== Multilib ==
Line 62: Line 95:
  
 
  CC="gcc ${BUILD32}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH32}" USE_ARCH=32 \
 
  CC="gcc ${BUILD32}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH32}" USE_ARCH=32 \
  ./configure --prefix=/usr --sysconfdir=/etc/php --libdir=/usr/lib --localstatedir=/var \ --with-apxs2=/usr/sbin/apxs --with-mysql
+
  ./configure --prefix=/usr --sysconfdir=/etc/php --libdir=/usr/lib \
  make &&
+
    --localstatedir=/var --with-apxs2=/usr/sbin/apxs --with-mysql \
 +
    --with-layout=GNU &&
 +
  make
  
 
Install the package:
 
Install the package:
  
  make install
+
  make install &&
  mv -v /usr/bin/php-config{,-32}
+
  mv -v /usr/bin/php-config{,-32} &&
  cp php.ini-recommended /etc/php/php.ini
+
  cp php.ini-production /etc/php/php.ini
  
The installscript change your Apache config and add the entry: "LoadModule php4_module   lib/apache/libphp4.so"
+
The installscript change your Apache config and add the entry: "LoadModule php{{PHP-Version2}}_module   lib/apache/libphp{{PHP-Version2}}.so"
But it forgets to set the mime applicationtype. So go to the /etc/apache/httpd.conf and add fowlling line under
+
But it forgets to set the mime applicationtype. So go to the /etc/apache/httpd.conf and add following line in the <IfModule mime_module> section:
<IfModule mime_module>:
 
  
 
  AddType application/x-httpd-php .php .phtml .php3 .htm .html
 
  AddType application/x-httpd-php .php .phtml .php3 .htm .html
  
If you build also a 64Bit PHP, you must:
+
When you want start a site with php-code, you must add:
 +
 
 +
IfModule dir_module>
 +
    DirectoryIndex index.html index.php index.php3 index.htm
 +
</IfModule>
 +
 
 +
 
 +
If you also choose to build a 64Bit PHP, you must:
 
   
 
   
 
  rm -f /etc/php/pear.conf
 
  rm -f /etc/php/pear.conf
  
 +
----
 +
 +
=== 64Bit ===
 +
 +
Compile the package:
 +
 +
CC="gcc ${BUILD64}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH64}" USE_ARCH=64 MYSQL_LIB_DIR=/usr/lib64 \
 +
./configure --prefix=/usr --sysconfdir=/etc/php \
 +
    --libdir=/usr/lib64 --localstatedir=/var \
 +
    --with-apxs2=/usr/sbin/apxs --with-mysql \
 +
    --with-layout=GNU &&
 +
make
 +
 +
Install the package:
 +
 +
make install
 +
mv -v /usr/bin/php-config{,-64}
 +
ln -sfv multiarch_wrapper /usr/bin/php-config
 +
cp php.ini-production /etc/php/php.ini
 +
 +
The installscript change your Apache config and add the entry: "LoadModule php{{PHP-Version2}}_module  lib64/apache/libphp{{PHP-Version2}}.so"
 +
But it forgets to set the mime applicationtype. So go to the /etc/apache/httpd.conf and add the following line in the <IfModule mime_module> section:
 +
 +
AddType application/x-httpd-php .php .phtml .php3 .htm .html
 +
 +
When you want start a site with php-code, you must add:
 +
 +
<IfModule dir_module>
 +
    DirectoryIndex index.html index.php index.php3 index.htm
 +
</IfModule>
 +
 +
{{Note|If you have a 32bit Apache then make sure you have the following in httpd.conf:
 +
LoadModule php{{PHP-Version2}}_module  lib/apache/libphp{{PHP-Version2}}.so
 +
If you have a 64bit Apache then make sure you have the following in httpd.conf:
 +
LoadModule php{{PHP-Version2}}_module  lib64/apache/libphp{{PHP-Version2}}.so
 +
}}
  
NOTE: NOT FINISHED YET! PLEASE WATCH OUT!
+
[[Category:Programming]]

Latest revision as of 12:34, 2 January 2011

Download Source: http://us2.php.net/get/php-5.3.2.tar.bz2/from/us.php.net/mirror

Introduction to PHP

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Project Homepage: http://www.php.net/

Warning:

The PHP Developer team means:

"We do not recommend using a threaded MPM in production with Apache2. Use the prefork MPM instead, or use Apache1. For information on why, read the related FAQ entry on using Apache2 with a threaded MPM"[1]"

Dependencies

Required

Optional

Configuration Information

See the output of ./configure --help for many more configuration options.

If you use Apache 1 then you must use --with-apxs instead --with-apxs2

If you want use Libmcrypt then you must add --with-mcrypt to the configure script


Caution.png

Note

PHP does not use DESTDIR, it uses INSTALL_ROOT for the same purpose. Use INSTALL_ROOT as you would normally use DESTDIR. There are some errors that are safe to ignore. It also will fail if it does not find a valid httpd.conf in the < DIRECTORY >etc/apache folder. one way to fix this is

install -d <DIRECTORY>/etc/apache && cp /etc/apache/httpd.conf <DIRECTOR>/etc/apache/

or figure out a way to fake the httpd.conf. remember to deal with the new data in httpd.conf with your installer
Caution.png

Note

There are some reproducable problems with PHP on both x86 and x86_64 architecture when compiling with GCC4 and -O3 optimization (see for example http://bugs.gentoo.org/show_bug.cgi?id=211611, there are more).

Non-Multilib

Compile the package:

./configure --prefix=/usr --sysconfdir=/etc/php \
    --libdir=/usr/lib --localstatedir=/var \
    --with-apxs2=/usr/sbin/apxs --with-mysql \
    --with-layout=GNU &&
make

Install the package:

make install
cp php.ini-production /etc/php/php.ini

The install script changes your Apache configuration and adds the entry: "LoadModule php5_module lib/apache/libphp5.so". But it forgets to set the mime application type. Open /etc/apache/httpd.conf and add following line in the <IfModule mime_module> section:

AddType application/x-httpd-php .php .phtml .php3 .htm .html

When you want start a site with php-code, you must add:

<IfModule dir_module>
   DirectoryIndex index.html index.php index.php3 index.htm
</IfModule>

To test your PHP installation, try this:

cat > /srv/www/htdocs/phptest.php << "EOF"

 
 PHP-Testpage
 
 
 
  
 
EOF
/etc/rc.d/init.d/apache restart
lynx localhost/phptest.php

Multilib

32Bit

Compile the package:

CC="gcc ${BUILD32}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH32}" USE_ARCH=32 \
./configure --prefix=/usr --sysconfdir=/etc/php --libdir=/usr/lib \
    --localstatedir=/var --with-apxs2=/usr/sbin/apxs --with-mysql \
    --with-layout=GNU &&
make

Install the package:

make install &&
mv -v /usr/bin/php-config{,-32} &&
cp php.ini-production /etc/php/php.ini

The installscript change your Apache config and add the entry: "LoadModule php5_module lib/apache/libphp5.so" But it forgets to set the mime applicationtype. So go to the /etc/apache/httpd.conf and add following line in the <IfModule mime_module> section:

AddType application/x-httpd-php .php .phtml .php3 .htm .html

When you want start a site with php-code, you must add:

IfModule dir_module>
   DirectoryIndex index.html index.php index.php3 index.htm
</IfModule>


If you also choose to build a 64Bit PHP, you must:

rm -f /etc/php/pear.conf

64Bit

Compile the package:

CC="gcc ${BUILD64}" PKG_CONFIG_PATH="${PKG_CONFIG_PATH64}" USE_ARCH=64 MYSQL_LIB_DIR=/usr/lib64 \
./configure --prefix=/usr --sysconfdir=/etc/php \
    --libdir=/usr/lib64 --localstatedir=/var \
    --with-apxs2=/usr/sbin/apxs --with-mysql \
    --with-layout=GNU &&
make

Install the package:

make install
mv -v /usr/bin/php-config{,-64}
ln -sfv multiarch_wrapper /usr/bin/php-config
cp php.ini-production /etc/php/php.ini

The installscript change your Apache config and add the entry: "LoadModule php5_module lib64/apache/libphp5.so" But it forgets to set the mime applicationtype. So go to the /etc/apache/httpd.conf and add the following line in the <IfModule mime_module> section:

AddType application/x-httpd-php .php .phtml .php3 .htm .html

When you want start a site with php-code, you must add:

<IfModule dir_module>
   DirectoryIndex index.html index.php index.php3 index.htm
</IfModule>
Caution.png

Note

If you have a 32bit Apache then make sure you have the following in httpd.conf:
LoadModule php5_module   lib/apache/libphp5.so

If you have a 64bit Apache then make sure you have the following in httpd.conf:

LoadModule php5_module   lib64/apache/libphp5.so