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.

Read More

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.

Related posts

Leave a Reply

5 comments

  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
    
  2. 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.

  3. 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.

  4. 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.

  5. 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,