Apache shows PHP code instead of executing it

前端 未结 26 1570
爱一瞬间的悲伤
爱一瞬间的悲伤 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:01

    In my case with PHP7.3 Apache2.4 Ubuntu 18.04 I had to execute:

    $ a2enmod actions fastcgi alias proxy_fcgi
    
    0 讨论(0)
  • 2020-11-22 03:02

    if the module userdir is enabled and your site is in a userdir (~/public_html) you must check /etc/apache2/mods-enabled/php5.conf. The following part makes it work (on Ubuntu 14.10 utopic):

    # Running PHP scripts in user directories is disabled by default
    # 
    # 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.
    
    # <IfModule mod_userdir.c>
    #     <Directory /home/*/public_html>
    #        php_admin_flag engine Off
    #    </Directory>
    # </IfModule>
    
    0 讨论(0)
  • 2020-11-22 03:03

    Wow, lots of solutions here! Here's what I did on Ubuntu 16.04:

    sudo apt-get install php libapache2-mod-php
    sudo a2enmod mpm_prefork && sudo a2enmod php7.0
    sudo service apache2 restart
    
    0 讨论(0)
  • 2020-11-22 03:03

    A different answer that worked for me. Is that, to install [sudo] apt-get install libapache2-mod-php5.X

    0 讨论(0)
  • 2020-11-22 03:03

    none of the above applied or worked for me... PHP7, Apache Httpd 2.2 on CentOS 6

    fact is, I installed (all with yum) php BEFORE Apache... you must do the reverse: always install Apache first, then PHP, and then it works... Indeed, you are likely missing libphp7.so and libphp7-zts.so in /etc/httpd/modules/

    I was able to recover anyhow without UNinstalling PHP. I did add the magic line in /etc/httpd/conf/httpd.conf: AddType application/x-httpd-php .php And then run: yum install php php-mysql

    0 讨论(0)
  • 2020-11-22 03:04

    open the file

    /etc/apache2/httpd.conf

    and change

    #LoadModule php5_module libexec/apache2/libphp5.so
    

    into

    LoadModule php5_module libexec/apache2/libphp5.so
    

    So just uncoment the PHP module load in httpd.conf

    0 讨论(0)
提交回复
热议问题