1. 检测apache正在使用哪个MPM?
XXX@XXX-ThinkPad-Edge-E431:~$ apachectl -V | grep -i mpm Server MPM: prefork
2. 列出可用的MPM模块(确保mpm_worker在列表中)
XXX@XXX-ThinkPad-Edge-E431:~$ ls /etc/apache2/mods-available/mpm* /etc/apache2/mods-available/mpm_event.conf /etc/apache2/mods-available/mpm_event.load /etc/apache2/mods-available/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.load /etc/apache2/mods-available/mpm_worker.conf /etc/apache2/mods-available/mpm_worker.load
3. 列出开启的MPM模块(如果mpm_worker没有开启,我们应该开启mpm_worker,禁用mpm_prefork模块)
XXX@XXX-ThinkPad-Edge-E431:~$ ls -l /etc/apache2/mods-enabled/mpm* lrwxrwxrwx 1 root root 34 10月 29 11:04 /etc/apache2/mods-enabled/mpm_prefork.conf -> ../mods-available/mpm_prefork.conf lrwxrwxrwx 1 root root 34 10月 29 11:04 /etc/apache2/mods-enabled/mpm_prefork.load -> ../mods-available/mpm_prefork.load
4. 禁用MPM_PREFORK模块
XXX@XXX-ThinkPad-Edge-E431:~$ sudo a2dismod mpm_prefork [sudo] password for XXX: Module mpm_prefork disabled. To activate the new configuration, you need to run: service apache2 restart
5. 开启MPM_WORKER模块
XXX@XXX-ThinkPad-Edge-E431:~$ sudo a2enmod mpm_worker Considering conflict mpm_event for mpm_worker: Considering conflict mpm_prefork for mpm_worker: Considering conflict mpm_itk for mpm_worker: Enabling module mpm_worker. To activate the new configuration, you need to run: service apache2 restart
6. 重新启动apache服务。
XXX@XXX-ThinkPad-Edge-E431:~$ sudo service apache2 restart * Restarting web server apache2 [fail] * The apache2 configtest failed. Output of config test was: [Wed Jan 06 18:05:55.525309 2016] [:crit] [pid 11501:tid 140459254396800] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP. AH00013: Pre-configuration failed Action 'configtest' failed. The Apache error log may have more information.
重新启动时,会报错误:待解决。
7. 检测apache是否运行在MPM_WORKER
XXX@XXX-ThinkPad-Edge-E431:~$ apachectl -V |grep -i mpm Server MPM: worker