Linux系统上把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=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 (这一项手工添加)
【相关文章】

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

DMA in C refers to DirectMemoryAccess, a direct memory access technology, allowing hardware devices to directly transmit data to memory without CPU intervention. 1) DMA operation is highly dependent on hardware devices and drivers, and the implementation method varies from system to system. 2) Direct access to memory may bring security risks, and the correctness and security of the code must be ensured. 3) DMA can improve performance, but improper use may lead to degradation of system performance. Through practice and learning, we can master the skills of using DMA and maximize its effectiveness in scenarios such as high-speed data transmission and real-time signal processing.

Handling high DPI display in C can be achieved through the following steps: 1) Understand DPI and scaling, use the operating system API to obtain DPI information and adjust the graphics output; 2) Handle cross-platform compatibility, use cross-platform graphics libraries such as SDL or Qt; 3) Perform performance optimization, improve performance through cache, hardware acceleration, and dynamic adjustment of the details level; 4) Solve common problems, such as blurred text and interface elements are too small, and solve by correctly applying DPI scaling.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

The main functions of ApacheHTTPServer include modular design, virtual host configuration and performance optimization. 1. Modular design implements functions by loading different modules, such as SSL encryption and URL rewriting. 2. Virtual host configuration allows multiple websites to be run on one server. 3. Performance optimization improves performance by adjusting parameters such as ServerLimit and KeepAlive.

macOS and Linux have their own advantages in compatibility and user experience. macOS has excellent compatibility within the Apple ecosystem, and the user experience is simple and intuitive; Linux has outstanding hardware compatibility and software flexibility. The user experience varies from distribution to distribution, emphasizing personalization and control.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.
