Apache is downloading php files instead of displaying them

后端 未结 26 1131
陌清茗
陌清茗 2020-11-22 01:03

OS and server information:

  • CentOS 6.4 (Final)
  • Apache 2.2.15
  • PHP 5.5.1

I previously had php 5.3.x installed but decided to upgr

相关标签:
26条回答
  • 2020-11-22 01:38

    I had similar symptoms, yet another solution: in /etc/apache2/mods-enabled/php5.conf there was a helpful advice in the comment, which I followed:

    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    
    0 讨论(0)
  • 2020-11-22 01:39

    I had this problem and if you actually never played with your server configuration settings, then your problem is 90% in your .htaccess file

    You either modify .htaccess file LOCALLY, ore delete it (LOCALLY)

    0 讨论(0)
  • 2020-11-22 01:41

    I have the same problem. Apache doesn't load php files from a certain website, just downloaded it. I read this post and the answers and I have seen I've got this line into the last place of the .htaccess file:

    AddHandler x-mapp-php5.5  .php
    

    I have commented it and everything works fine.

    Thanks to all !!!

    0 讨论(0)
  • 2020-11-22 01:41

    When i upgraded from PHP 7.2 to PHP 7.4, i also got same issue. Worked by doing following:-

    1. In [domain].conf file, commented following:

      php_admin_value engine Off
      

      And Added:

      AddType  application/x-httpd-php-source  .phps
      AddType text/html .php
      
    2. Disable mod 7.2 and enable 7.4 by following:

      a2dismod php7.2
      a2enmod php7.4
      
    3. In /etc/apache2/mods-enabled/php7.4.conf file, comment following:

      SetHandler application/x-httpd-php
      php_admin_flag engine Off
      
    0 讨论(0)
  • 2020-11-22 01:42

    PHP56

    vim /etc/httpd/conf/httpd.conf

    LoadModule php5_module        libexec/apache/libphp5.so
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
    0 讨论(0)
  • 2020-11-22 01:43

    After updating PHP to 7.3, PHP scripts where run with www-data instead of $USER like before.

    I needed to reinstall and activate PHP-FPM :

    sudo apt-get install php-fpm
    sudo a2enmod proxy_fcgi setenvif
    sudo service apache2 restart
    sudo a2enconf php7.3-fpm
    sudo service apache2 restart
    

    To ensure everything was ok for Virtualmin, i used the Re-Check Configuration wizard /virtual-server/check.cgi, under Vitualmin/System Settings.

    After that, Apache/PHP was downloading php files instead of running them. So i needed to edit /etc/apache2/mods-available/php7.3.conf to comment the row SetHandler application/x-httpd-php like below :

    <FilesMatch ".+\.ph(ar|p|tml)$">
    #    SetHandler application/x-httpd-php
    </FilesMatch>
    

    After restarting Apache, it solved my issue, hope this help.

    Take care of browser cache too.

    My system :

    Ubuntu          16.04.6 LTS
    Webmin version      1.932
    Usermin version     1.780
    Virtualmin version  6.08
    Apache version      2.4.41
    PHP versions        7.3.12
    PHP-FPM         7.3.12 Server
    
    0 讨论(0)
提交回复
热议问题