Compile PHP into Apache static Kernel on Linux

Source: Internet
Author: User

There are two ways to integrate Apache into PHP: one is the DSO mode, which calls PHP as an external module of Apache, which increases the flexibility of Apache, but reduces the performance by 5%; another way is to compile PHP into the Apache kernel, which sacrifices the flexibility of future adjustments (Apache needs to be compiled every time PHP is re-compiled ), however, the performance is higher. This is also true for Perl. In contrast, I prefer to use the second method, that is, to compile PHP into the static kernel of Apache.

1. Compile Apache:

1. Go to Apache to expand the 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 module of Apache

(Note: If DSO is used later,--enable-mdule = so will be added during compilation)

2. install PHP:

1. Go to PHP to expand the directory;

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

--With-apache = ../apache_1.3.27 # specify the Apache source code directory.

3. make; make install

3. install Apache:

1. Go to Apache to expand the 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 # compile the PHP module

3. make; make install

4. Configure Apache:

Modify httpd. conf:

1,Timeout 300 ---> Timeout 120

2,MaxKeepAliveRequests 100

3,KeepAliveTimeout 5

4,ServerSignature on ---> ServerSignature off

5,Options Indexes FollowSymLinks row deletes indexes (the Options of the directory does not contain the index option)

6,Change the user and group running Apache to nobody.

7,MaxClients 150 --> MaxClients 1500

(This parameter has a basic algorithm, such as a 2 GB machine. An Apache + PHP process consumes about 4 MB of memory, the maximum number of processes is 2g/4 m * 2 = 1000, and the maximum number of processes is 1000*1.5 = 1500; 1.3 to be adjusted to higher than 256, you must modify the source code before compiling Apache)

(For apache2.0, set MaxClients 150 --> MaxClients 1500 in the worker MPM field)

8,Add index. php to DirectoryIndex index.html. var.

9,Find the section that contains 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:

Go to the Apache installation directory;

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

Make; make install

B,Install PHP:

Go to 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 perform the preceding configuration;

In addition, the modification is as follows:

LoadModule php4_module modules/libphp4.so (this item is automatically added after php is installed)

AddType application/x-httpd-php. php (this item is manually added)

[Related articles]


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.