Linux系统上把PHP编译进Apache静态内核

发表于:2008-04-25来源:作者:点击数: 标签:内核linuxLinux静态Apache
关键字:Apache静态内核说明:Apache整合 PHP 有两种方式:一种是DSO模式,把PHP当作Apache的外部模块来调用,这样增加了Apache的灵活性,但会带来5%的 性能 降低;另一种方式是把PHP编译进Apache的内核,这样牺牲了以后调整的灵活性(每次对PHP的重新编译,
关键字:Apache静态内核说明:Apache整合PHP有两种方式:一种是DSO模式,把PHP当作Apache的外部模块来调用,这样增加了Apache的灵活性,但会带来5%的性能降低;另一种方式是把PHP编译进Apache的内核,这样牺牲了以后调整的灵活性(每次对PHP的重新编译,都需要再次编译Apache),但性能会高一些。对Perl也是如此。相比之下,本人更愿意使用第二种方式,即把PHP编译进Apache的静态内核。 


一.编译Apache: 


1. 进入Apache展开目录; 


2. ./configure - -prefix=/usr/local/apache1.3 - -disable-module=all\ 

- -enable-module=aclearcase/" target="_blank" >ccess - -enable-module=log_config \ 

- -enable-module=dir - -enable-module=mime \ ##Apache工作的基本模块 

(说明:如果以后使用DSO方式,则编译时加上 - -enable-mdule=so) 


二.安装PHP: 


1. 进入PHP展开目录; 


2. ./configure - -prefix=/usr/local/php4 \ 

- -with-apache=../apache_1.3.27 ##这里指定Apache的源代码目录 

3. make;make install 


三.安装Apache: 


1. 进入Apache展开目录; 


2. ./configure - -prefix=/usr/local/apache1.3 - -disable-module=all \ 

- -enable-module=access - -enable-module=log_config \ 

- -enable-module=dir - -enable-module=mime \ 

- -activate-module=src/modules/php4/libphp4.a ##把PHP模块编译进去 


3. make;make install 


四。配置Apache: 

修改httpd.conf文档: 

1.Timeout 300--->Timeout 120 

2.MaxKeepAliveRequests 100 

3.KeepAliveTimeout 5 

4.ServerSignature on--->ServerSignature off 

5.Options Indexes FollowSymLinks 行把indexes删掉(目录的Options不要带index选项) 

6.将Apache运行的用户和组改为nobody 

7.MaxClients 150——>MaxClients 1500 

(该参数是多少有一个基本的算法,例如2G的机器,一个Apache+PHP进程大概消耗4M内存,则最高效率的进程数为2g/4m * 2=1000,最大进程数为1000*1.5=1500;1.3下要调整到高于256须在编译Apache前修改其源代码) 

(对apache2.0版本,将worker MPM字段里的MaxClients 150——>MaxClients 1500) 

8.DirectoryIndex index.html index.html.var 后面加上index.php 

原文转自:http://www.ltesting.net