Home > Backend Development > PHP Tutorial > Compile PHP into Apache static kernel on Linux system_PHP tutorial

Compile PHP into Apache static kernel on Linux system_PHP tutorial

WBOY
Release: 2016-07-15 13:24:24
Original
953 people have browsed it

There are two ways for Apache to integrate PHP: one is the DSO mode, which calls PHP as an external module of Apache, which increases the flexibility of Apache, but will bring about a 5% performance reduction; the other is One way is to compile PHP into the Apache kernel, which sacrifices the flexibility of future adjustments (every time PHP is recompiled, Apache needs to be compiled again), but the performance will be higher. The same is true for Perl. In contrast, I prefer to use the second method, which is to compile PHP into Apache's static kernel.

1. Compile Apache:

1. Enter the Apache expansion directory;

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

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

- -enable-module=dir - -enable-module=mime ##Basic modules for Apache work

(Note: If you use DSO in the future, add - -enable-mdule=so when compiling)

2. Install PHP:

1. Enter the PHP expansion directory;

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

- -with-apache=.. /apache_1.3.27 ##Specify the source code directory of Apache here

3. make; make install

3. Install Apache:

1. Enter the Apache expansion directory;

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 ## Put PHP The module is compiled into

3. make;make install

4. Configure Apache:

Modify the httpd.conf file:

1, Timeout 300--->Timeout 120

2 , MaxKeepAliveRequests 100

3, KeepAliveTimeout 5

4, ServerSignature on--->ServerSignature off

5. Delete indexes in the Options Indexes FollowSymLinks line (do not include the index option in the directory's Options)

6. Change the user and group that Apache runs under to nobody

7. MaxClients 150——>MaxClients 1500

(This parameter has a basic algorithm. For example, on a 2G machine, an Apache+PHP process consumes about 4M of memory. Then the most efficient number of processes is 2g/4m * 2 = 1000, and the maximum number of processes is 1000 * 1.5 = 1500; to adjust to a value higher than 256 under 1.3, the source code must be modified before compiling Apache)

( For the apache2.0 version, add MaxClients 150——>MaxClients 1500) in the worker MPM field

8, DirectoryIndex index.html index.html.var followed by index.php

9. Find the section containing a large number of AddType commands and add the following line: AddType application/x-httpd-php .php

Apache version: Apache-2.0.47

PHP version: PHP-4.3.2

a, Install Apache:

Enter the Apache installation directory;

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

make;make install

b、Install PHP:

Enter the PHP installation directory;

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

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

make;make install

c, Configure Apache:

Modify httpd.conf and follow the above configuration;

Additional modifications:

LoadModule php4_module modules/libphp4.so (this item will be added automatically after installing php)

AddType application/x-httpd-php .php (this A manual addition)

[Related articles]


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446779.htmlTechArticleThere are two ways for Apache to integrate PHP: one is DSO mode, which calls PHP as an external module of Apache , which increases the flexibility of Apache, but will bring about 5% performance reduction; another way...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template