Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php and apache thread safe error

Tags:

I am running php 5.5 and apache 2 on debian 7 (wheezy) i have installed php module for apache but it's not enable whithout enabling php module for apache i will see php files as plain text and when i enabled php module whith a2enmod i can not start apache and it gives this error

[crit] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP. Pre-configuration failed Action 'configtest' failed.

how can i fix this problem

like image 935
zoli Avatar asked Oct 04 '13 15:10

zoli


People also ask

Is PHP thread safe?

If you choose to run PHP as a CGI binary, then you won't need thread safety, because the binary is invoked at each request. For multithreaded webservers, such as IIS5 and IIS6, you should use the threaded version of PHP.

What is the difference between NTS and TS?

The difference of NTS and TS is in the name itself. TS = Thread Safe. NTS = Non Thread Safe. Though the non checking of thread safty the NTS version is a very little faster.

What is thread safe code?

Thread safety is a computer programming concept applicable to multi-threaded code. Thread-safe code only manipulates shared data structures in a manner that ensures that all threads behave properly and fulfill their design specifications without unintended interaction.


2 Answers

Disabling mpm_event and enabling mpm_prefork worked for me.

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
like image 87
Anbazhagan p Avatar answered Sep 23 '22 20:09

Anbazhagan p


Test the Apache configuration:

apache2ctl configtest

Install PHP and PHP-FPM:

sudo apt-get install php7.0
sudo apt-get install php7.0-fpm

Enable Apache PHP7 module:

sudo a2enmod php7.0

Disable mpm_event module:

sudo a2dismod mpm_event

Enable mpm_prefork module:

sudo a2enmod mpm_prefork

Finally restart Apache:

sudo service apache2 restart

This will resolve your error.

like image 39
Roshan Weerasuriya Avatar answered Sep 20 '22 20:09

Roshan Weerasuriya