Apache shows PHP code instead of executing it

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

    Debian 9 solution:

    touch /etc/apache2/conf-available/php.conf 
    

    Add to file next lines:

    <IfModule mod_php5.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
    </IfModule>
    <IfModule mod_php.c>
        <IfModule mod_mime.c>
            AddType application/x-httpd-php .php
        </IfModule>
        <FilesMatch ".+\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
    </IfModule>
    

    Then run:

    a2enconf php && service apache2 restart
    
    0 讨论(0)
  • 2020-11-22 03:28

    Some times if you have php version conflicts it happens To overcome that please follow the below steps

    Step 1 : Yum list installed | grep 'php'

    if you have multiple versions of php like php 5.6 and php 7.0 this confilict will happens

    Step 2 : yum remove **your php version **

    Step 3 : Then restart the apapche /etc/init.d/httpd restart or service apache2 restart

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