A. Z.
A. Z.

Reputation: 736

Don't know why Apache server sends PHP-files to download instead of run them

Got a problem with Apache and PHP-files of Wordpress.

When I go to any WP's page, browser try to download PHP-file as a static one. I created test.php with <?php echo 'test'; ?> and it runs normally.


Solved! I found that php5.conf was disebled: /etc/apache2/mods-enabled/php5.conf.disabled. PHP works after renaming it.


I run a clean image of Debian 6, installed Apache and PHP 5.3 (within ISPmanager), made a PHP-enabled domain and copied a Wordpress installation from shared hosting. So everything here is from stack, not modified and should work.

There was a similar question, but it wasn't resolved: Why browser is trying to download my php script file?.

If anyone knows the answer, I would appreciate it. Thanks.

Upvotes: 1

Views: 4218

Answers (5)

Shankaranand
Shankaranand

Reputation: 83

I was also very upset for this problem and finally I have got a solution.

Here is the solutions.

Step -1 : Run this command.

sudo apt-get install libapache2-mod-php5

Step -2: Enable it.

sudo a2enmod php5

Step-3 : Restart apache.

sudo service apache2 restart

Note:Sometime, when you run the 1st command then it will enable as well as restart the apache then you don't need to run the step-2 and step-3.

For any help,please write the comment.

Thanks,

Upvotes: 0

swellest
swellest

Reputation: 1

This can happen in a regular browser environment too. If you have that issue you can try to use your local IP address and web server port in the browser's address bar. I had that problem when typing /var/www/foo.php in the address bar. The browser was looking for a local address to download a file from. Try exp 192.168.0.6:80/foo.php. That fixed my problem.

Upvotes: 0

schmijos
schmijos

Reputation: 8695

Does the webservers unix user have the execution rights for the PHP-file?

Check in your ftp-client if the files have 'rwx' as theirs rights attributes.

Upvotes: 0

Ivan Nikitin
Ivan Nikitin

Reputation: 4125

You have a "space" char between question sign and "php". Remove it. This should solve the problem.

If this doesn't help, check that PHP is properly configured. Open your httpd.conf file and check for these lines:

LoadModule php5_module php5apache2.so
AddType application/x-httpd-php .php 
AddType application/x-httpd-php-source .phps

Upvotes: 1

itsme
itsme

Reputation: 575

Usually is it because there is something in the code which the browser couldn't read so instead the browser downloaded it, the solution is only to debug your code and see whats your problem is.

Upvotes: 0

Related Questions