参考 :
http://www.ehow.com/how_12021626_activate-worker-mpm-apache2-ubuntu.html
背景: apache2,php5默认安装的时候都是使用的 mpm_prefork 模式, 我们想要将其调整为mpm_worker模式,问题来了,php5与mpm_worker不兼容的,如何处理?
ubuntu 14.04 apache2.4.x php5.x.x
1. 安全先备份 php.ini
写道
cd /etc/php5/cgi/
sudo cp php.ini php.ini.back
sudo cp php.ini php.ini.back
2. 安装 Apache2 worker MPM
写道
sudo apt-get install apache2-mpm-worker php5-cgi
** 可能会提示 the "apache2-mpm-prefork" and "libapache2-mod-php5" are removed.
** 可能会提示 the "apache2-mpm-prefork" and "libapache2-mod-php5" are removed.
3. 启用cgi和cgid
写道
sudo a2enmod cgi
sudo a2enmod cgid
sudo a2enmod cgid
4. 激活 mod_actions
写道
cd /etc/apache2/mods-enabled
sudo ln -sf ../mods-available/actions.load
sudo ln -sf ../mods-available/actions.conf
sudo ln -sf ../mods-available/actions.load
sudo ln -sf ../mods-available/actions.conf
5. 编辑 actions.conf
写道
<IfModule mod_actions.c>
Action application/x-httpd-php /cgi-bin/php5
</IfModule>
Action application/x-httpd-php /cgi-bin/php5
</IfModule>
6. 编辑 apache2.conf
写道
sudo vim /etc/apache2/apache2.conf
<IfModule mpm_worker_module> StartServers 10 ServerLimit 1000 MaxClients 1000 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0 </IfModule>
7. 检查语法都对了没有
写道
/usr/sbin/apache2ctl -t
** 成功会有 "Syntax OK" 字样
** 成功会有 "Syntax OK" 字样
8. 重启 apache
写道
sudo /etc/init.d/apache2 restart
** 我在操作的时候 (ubuntu server 14.04 64bit时 出现 worker还原成 prefork的情况 )
写道
sudo a2dismod mpm_prefork
sudo a2enmod mpm_worker
sudo a2enmod mpm_worker
重新启用mpm_worker即可