Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  138] [ 0]  / answers: 1 / hits: 368032  / 1 Year ago, mon, december 5, 2022, 1:43:52

I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a "download" file. And when I try documentroot/index.php it just downloads the PHP file.



I have PHP installed but Apache doesn't seem to want to execute it.

People suggested adding a 'Load Module' line to my httpd.conf but I don't have that file.


More From » apache2

 Answers
6

Typing:



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


will install everything you need and will start the apache server with support for PHP.



To verify that the php module is loaded, type:



a2query -m php5


if not enabled, then load with:



sudo a2enmod php5


and restart apache:



sudo service apache2 restart


Update for php7.x (tested on Ubuntu 16.04, 16.10, 18.04, 18.10)



Thanks to the comments, I update the answer for php7.x.



Install:



sudo apt-get install apache2 php7.x libapache2-mod-php7.x 


Verify:



a2query -m php7.x


Load:



sudo a2enmod php7.x


Restart apache:



sudo service apache2 restart

[#25846] Tuesday, December 6, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byishted

Total Points: 469
Total Questions: 113
Total Answers: 113

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;