james clarke
james clarke

Reputation: 243

Apache installing and running php files

Im having some problems with running php files on my apache server. i have installed php 7, the folder /etc/php/7.0 exists which shows it's installed. I have configured apache to run .php files, however in my /etc/apache2/mods-enabled folder there isn't a php.conf file. Any ideas about how to install it?

(im on raspbian), apache version 2.4.25

Upvotes: 13

Views: 40402

Answers (3)

Lukasz Czerwinski
Lukasz Czerwinski

Reputation: 15432

Running:

  1. sudo a2dismod mpm_event
  2. sudo systemctl restart apache2
  3. sudo a2enmod mpm_prefork
  4. sudo systemctl restart apache2
  5. sudo a2enmod php7.0
  6. sudo systemctl restart apache2

worked for me.

Upvotes: 56

mike
mike

Reputation: 111

I had this problem too. I upgraded from Ubuntu 17.04 to Ubuntu 17.10 and then php did not work and there was no php.conf file in /etc/apache2/mods-enabled. When I tried sudo a2enmod php7.1 I was given the same error:

Considering dependency mpm_prefork for php7.0:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!
Considering conflict mpm_worker for mpm_prefork:
ERROR: Could not enable dependency mpm_prefork for php7.0, aborting

I used sudo a2dismod mpm_event and received no errors. I restarted apache2 and then used sudo a2enmod php7.1 and it worked just fine. Restarted apache2 again and now php is working again and I can see phpinfo() in my browser when I couldn't before.

Upvotes: 11

Ervin Peza Hoxha
Ervin Peza Hoxha

Reputation: 1

There has to be a php.conf file in etc/apache2 otherwise it wont work you haven't installed it correctly.You might have not configured your installation together with mysql and apache.Read the install file in php source code folder and then recompile with apache and mysql so you can have Lamp in your Ubuntu installation for example :

./configure --with-mysql --with-apache2 and so on 

make

make install

Upvotes: 0

Related Questions