Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache2 on ubuntu - php files downloading

Tags:

php

apache

ubuntu

On my new Ubuntu system, I've managed to get Apache2 up and running for developing my ZendFramework Web Applications...

I've got my available-sites config working correctly because I am able to request localhost and it servers up the correct index.html from my specified directory.

Problem : if I request index.php, firefox attempts to download the file instead of running the script.

Any Ideas why this would happen?

I've added the following to httpd.conf but it hasn't helped.

AddHandler application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml  AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml 
like image 577
shane Avatar asked Jun 05 '11 21:06

shane


People also ask

Why is my PHP file downloading instead of running?

This is normally due to an improper handler code. In the . htaccess file, you will want to ensure the handler code matches your version of php. If it does not, the php files may try to download instead of process.

Can PHP files be downloaded?

Generally, no PHP script is required to download a file with the extensions exe and zip. If the file location of this type of file is set in the href attribute of the anchor element, then the file automatically downloads when the user clicks on the download link.

Where do I put PHP files in Apache?

php. This component saves the uploaded file to a folder named upload in the Apache server's htdocs directory.


1 Answers

If Firefox downloads your PHP files it means that your server doesn't have PHP or the Apache PHP module installed.

Have you installed the Apache PHP module? If not then install it by typing this into a terminal:

sudo apt-get install libapache2-mod-php5 

And if yes, do you have your index.php located in /var/www/?

Make sure to enable PHP with the command

sudo a2enmod php5 
like image 191
Paris Liakos Avatar answered Sep 24 '22 18:09

Paris Liakos