1

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.

1
  • Solved. I found that php5.conf was disebled: /etc/apache2/mods-enabled/php5.conf.disabled. PHP works after renaming it. Commented Jun 24, 2012 at 22:04

5 Answers 5

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

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

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.

2 Comments

Not true, the only thing that will cause it is improper server configuration.
I had the same problem with a code which was copied from another and it was some mass there and I fixed it with debugging it.
0

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.

Comments

0

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.

Comments

0

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,

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.