Rumah  >  Artikel  >  pembangunan bahagian belakang  >  Linux系统上把PHP编译进Apache静态内核_PHP教程

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

WBOY
WBOYasal
2016-07-15 13:24:24893semak imbas

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=access - -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

9、查找包含大量AddType命令的小节,添加下面这一行: AddType application/x-httpd-php .php

Apache版本:Apache-2.0.47

PHP版本:PHP-4.3.2

a、安装Apache:

进入Apache安装目录;

./configure - -prefix=/usr/local/apache2 - -enable-so

make;make install

b、安装PHP:

进入PHP安装目录;

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

-with-apxs2=/usr/local/apache2/bin/apxs

make;make install

c、配置Apache:

修改httpd.conf,上述配置工作照做;

另外修改的地方:

LoadModule php4_module modules/libphp4.so (这一项在装完php后会自动添加)

AddType application/x-httpd-php .php (这一项手工添加)

【相关文章】


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446779.htmlTechArticleApache整合PHP有两种方式:一种是DSO模式,把PHP当作Apache的外部模块来调用,这样增加了Apache的灵活性,但会带来5%的性能降低;另一种方式...
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn