从PHP到LAMP

PHP INSTALL

Apache 1.3.x on Unix systems(from php-5.3.8)

Example #1 Installation Instructions (shared Module Version) for PHP

# gunzip apache_xxx.tar.gz

# tar -xvf apache_xxx.tar

# gunzip php_xxx.tar.gz

# tar -xvf php_xxx.tar

# cd apache_xxx

# ./configure --prefix=/www --enable-module=so

# make && make install

# cd ../php_xxx

# ./configure --with-mysql --with-apxs=/www/bin/apxs

# make && make install

# cp php.ini-development /usr/local/lib/php.ini

下边的载入可能在PHP安装时已经加入了,需要再次确认一下

# vi /etc/httpd/conf/httpd.conf

> LoadModule php5_module libexec/libphp5.so

> :wq

And in the AddModule section of httpd.conf,somewhere under the ClearModuleList,add this:

# vi /etc/httpd/conf/httpd.conf

> AddModule mod_php5.c

> :wq

# vi /etc/httpd/conf/httpd.conf

> AddType application/x-httpd-php .php .phtml

> AddType application/x-httpd-php-source .phps

> :wq

重启apache,来加载php模块。Ok了!

Example #2 Installation Instructions (Static Module) for PHP

# gunzip -c apache_1.3.x.tar.gz | tar xf -

# cd apache_1.3.x

# ./configure

# cd ..

# gunzip -c php-5.x.y.tar.gz | tar xf -

# cd php-5.x.y

# ./configure --with-mysql --with-apache=../apache_1.3.x

# make

# make install

# cd ../apache_1.3.x

# ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a

# make

# make install(第一次安装,或者)

# cp httpd /www/bin/httpd

# cd ../php-5.x.y

# cp php.ini-development /usr/local/lib/php.ini

Edit httpd.conf file and add:

# vi httpd.conf

> AddType application/x-httpd-php .php

Example #3 Different example of compiling PHP for apache are as follows:

# ./configure --with-apxs --with-pgsql

This will create a libphp5.so shared library that is loaded into Apache using a LoadModule line in Apaches httpd.conf file.The PostgreSQL support is embedded into this library.

# ./configure --with-apxs --with-pgsql=shared

This will create a libphp5.so shared library for Apache,but it will also create a pgsql.so shared library that is loaded into PHP either by using the extension directive in php.ini file or by loading it explicitly in a script using the dl() function.

# ./configure --with-apache=/path/to/apache_source --with-pgsql

This will create a libmodphp5.a library,a mod_php5.c and some accompanying files and copy this into the src/modules/php5 directory in the Apache source tree. Then you compile Apache using --activate-module=src/modules/php5/libphp5.a and the Apache build system will create libphp5.a and link it statically into the httpd binary,so the final result here is a single httpd binary that includes all of Apache and all of PHP.

# ./configure --with-apache=/path/to/apache_source --with-pgsql=shared

Same as before,except instead of including PostgreSQL support directly into the final httpd you will get a pgsql.so shared library that you can load into PHPfrom either the php.ini file or directly suing dl().

Apache 2.x on Unix systems(from php-5.3.8)

# gzip -d httpd-2.x.NN.tar.gz

# tar -xf httpd-2.x.NN.tar

# gunzip php-NN.tar.gz

# tar -xf php-NN.tar

#

# cd httpd-2.x.NN

# ./configure --enable-so

# make

# make install

#

# cd ../php-NN

# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql

# make

# make install

#

# cp php-ini-development /usr/local/lib/php.ini

# vi /etc/local/apache2/conf/httpd.conf

> LoadModule php5_module modules/libphp5.so

>

> <FilesMatch \.php$>

>  SetHandler application/x-httpd-php

> </FilesMatch>

>

>  # Or,if we wanted to allow .php, .php2, .php3, .php4, .php5, .php6 and .phtml files to be executed as PHP,but nothing

>  # else,wed use this:

> <FilesMatch \.ph(p[2-6]?|tml)$>

>  SetHandler application/x-httpd-php

> </FilesMatch>

>

>  # And to allow .phps files to be handled by the php source filter,and displayed as syntax-highlighted source code,

>  # use this:

> <FileMatch \.phps$>

>  SetHandler application/x-httpd-php-source

> </FileMatch>

>

>

>

> :wq

#

Apache 1.3.x on Unix systems(PHP-5.4.6)

Example #1 Installation Instructions(Shared Module) for PHP

# gunzip apache_xxx.tar.gz

# tar -xvf apache_xxx.tar

# gunzip php-xxx.tar.gz

# tar -xvf php-xxx.tar

# cd apache_xxx

# ./configure --prefix=/www --enable-module=so

# make

# make install

#

# cd ../php-xxx

# ./configure --with-mysql --with-apxs=/www/bin/apxs

# make

# make install

#

# cp php.ini-development /usr/local/lib/php.ini

# vi /www/conf/httpd.conf

> LoadModule php5_module libexec/libphp5.so

> AddType application/x-httpd-php .php .phtml

>

> :wq

And in the Addmodule section of httpd.conf,somewhere under the ClearModuleList,add this:

> AddModule mod_php5.c

#

Example #2 Installation Instructions(Static Module) for PHP

# gunzip -c apache_1.3.x.tar.gz | tar xf -

# cd apache_1.3.x

# ./configure

# cd ..

#

#

# gunzip -c php-5.x.y.tar.gz | tar xf -

# cd php-5.x.y

# ./configure --with-mysql --with-apache=../apache_1.3.x

# make

# make install

#

# cd ../apache_1.3.x

# ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a

# make

# make install

#

# cd ../php-5.x.y

# cp php.ini-development /usr/local/lib/php.ini

#

Example #3 Different example of compiling PHP for apache are as follows:

# ./configure --with-apxs --with-pgsql

# ./configure --with-apxs --with-pgsql=shared

# ./configure --with-apache=/path/to/apache_source --with-pgsql

# ./configure --with-apache=/path/to/apache_source --with-pgsql=shared

# ./configure --with-apxs --with-pgsql

This will create a libphp5.so shared library that is loaded into Apache using a LoadModule line in Apaches httpd.conf file.The PostgreSQL support is embedded into this library.

# ./configure --with-apxs --with-pgsql=shared

This will create a libphp5.so shared library for Apache,but it will also create a pgsql.so shared library that is loaded into PHP either by using the extension directive in php.ini file or by loading it explicitly in a script using the dl() function.

# ./configure --with-apache=/path/to/apache_source --with-pgsql

This will create a libmodphp5.a library,a mod_php5.c and some accompanying files and copy this into the src/modules/php5 directory in the Apache source tree.Then you compile Apache using --activate-modules=src/modules/php5/libphp5.a and the Apache build system will create libphp5.a and link it statically into the httpd binary.The PostgreSQL support is included directly into this httpd binary,so the final result here is a single httpd binary that includes all of Apache and all of PHP.

# ./configure --with-apache=/path/to/apache_source --with-pgsql=shared

Same as before,except instead of including PostgreSQL support directly into the final httpd you will get a pgsql.so shared library that you can load into PHP from either the php.ini file or directly using dl() function.

Phpinfo()

<?php

Phpinfo();

?>


本文出自 “小崔的实验笔记” 博客,谢绝转载!

从PHP到LAMP,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。