Apache shows PHP code instead of executing it

前端 未结 26 1585
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 02:23

I have recently been trying to install PHP and Apache on my computer. After many hours, they\'re installed. I have modified the httpd.conf and php.ini files like everyone sa

26条回答
  •  礼貌的吻别
    2020-11-22 03:17

    For PHP 7 (May apply to previous versions as well), but I had to do this:

    Add this to the bottom of /etc/apache2/apache2.conf

    
    SetHandler application/x-httpd-php
    
    

    Run this from the terminal:

    sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php7
    

    Then don't forget to restart Apache so it knows you changed stuff:

    sudo service apache2 restart
    

    This is a summary from: https://www.atlantic.net/community/howto/try-php7-lamp-ubuntu-14-04/

提交回复
热议问题