Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 348
james clarke Avatar asked Oct 30 '17 21:10

james clarke


People also ask

Can I run PHP on Apache server?

Now Apache server is ready to run PHP codes. Let's understand how to run the first PHP code on the Apache server. For this open an editor write an example PHP code and save it in Apache24 > htdocs > projectfolder > filename. php.

Do I need to install PHP after Apache?

Apache comes bundled with PHP, so you don't need to install it manually. . NET: . NET is a popular software framework that you can use to build web applications and more.


2 Answers

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.

like image 173
Lukasz Czerwinski Avatar answered Sep 19 '22 21:09

Lukasz Czerwinski


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.

like image 41
mike Avatar answered Sep 20 '22 21:09

mike