runasas
runasas

Reputation: 21

enable php on apache2 (using Ubuntu 16.04)

I've installed Apache2 on my Ubuntu 16.04.1 System.

I want to install and activate PHP7.0 on my Webserver too.

I installed php and tried to activate the module in Apache2.

When restarting the server, I get:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

When I execute "systemctl status apache2.service, I get:

-- Unit apache2.service has begun starting up.
Jan 30 12:19:58 tom-450-a141ng apache2[29920]:  * Starting Apache httpd web server apache2
Jan 30 12:19:58 tom-450-a141ng apache2[29920]:  *
Jan 30 12:19:58 tom-450-a141ng apache2[29920]:  * The apache2 configtest failed.
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: Output of config test was:
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: [Mon Jan 30 12:19:58.942761 2017] [:crit] [pid 29935:tid 140264661432192] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. 
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: AH00013: Pre-configuration failed
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: Action 'configtest' failed.
Jan 30 12:19:58 tom-450-a141ng apache2[29920]: The Apache error log may have more information.
Jan 30 12:19:58 tom-450-a141ng systemd[1]: apache2.service: Control process exited, code=exited status=1
Jan 30 12:19:58 tom-450-a141ng systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit apache2.service has failed.
-- 
-- The result is failed.
Jan 30 12:19:58 tom-450-a141ng systemd[1]: apache2.service: Unit entered failed state.
Jan 30 12:19:58 tom-450-a141ng systemd[1]: apache2.service: Failed with result 'exit-code'.
Jan 30 12:19:58 tom-450-a141ng sudo[29892]: pam_unix(sudo:session): session closed for user root

So I can't start Apache anymore.

I've searched everywhere for a solution.

Plz help

Upvotes: 1

Views: 12694

Answers (3)

Arif
Arif

Reputation: 331

As you need to install php7, just remove the currently installed one using-

sudo apt-get purge php*

and then run

sudo apt-get -y install php7.0 libapache2-mod-php7.0

Then you can install other modules as per your need using-

apt-get -y install php7.0-mysql php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache

systemctl restart apache2

Upvotes: 8

Daniel Ferradal
Daniel Ferradal

Reputation: 2900

The error "[Mon Jan 30 12:19:58.942761 2017] [:crit] [pid 29935:tid 140264661432192] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe." describes that you are using a threaded MPM, that is, event or worker, but your mod_php module depends on a php installation that is not thread-safe, thus you can only use it with prefork.

If you want to use a threaded MPM (which is fine, a good idea too and I recommend it too), you should not use mod_php, you should use php-fpm instead.

You will find how to configure it in the Official Apache Wiki

Upvotes: 1

Rohit Sachan
Rohit Sachan

Reputation: 7

You can do this directly with below command

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Upvotes: 0

Related Questions