-1

I am running Apache 2.4.23, MySQL 5.1.73, and PHP 7.0.10

Upon calling my index.php with Apache in-browser, it shows me the source of the .php instead of what it should be showing (the results of the code).

I believe this is due to the lack of an associated .php module in my httpd.conf, however, my Google-Fu lends me no assistance.

Directories for my program installations:

Apache: /home/alexander/myPrograms/apache

MySQL: /home/alexander/myPrograms/MySQL

PHP: /home/alexander/myPrograms/PHP

Everything was compiled from source, not apt-get install (I have reasons, I swear!), so my directories may be a bit different than usual.

Any ideas/pointers for getting PHP 7 working for me?

1
  • If you don't have any idea what you do please install software from base-repo. add-on this is not an Ubuntu problem. This is a not proper apache configuration to meet your needs. Please ask google how to activate php-module in apache config to run php-scripts. You will find hints like this: dan.drydog.com/apache2php.html
    – 0x0C4
    Aug 24, 2016 at 6:03

1 Answer 1

0

You have to set up a handler for the PHP extension. In Ubuntu this is done by adding modules for the various component with an associated configuration file. The php configuration module for Ubunt 16.04 looks like this:

<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default                                                                               
    # To re-enable it's recommended to enable access to the files                                                             
    # only in specific virtual host or directory                                                                              
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')                                                                         
<FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
    Require all denied
</FilesMatch>

# 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>

One of the main configuration lines is:

SetHandler application/x-httpd-php
1
  • true, for Ubuntu but user compiled the software by his own. so this is not ubuntu specific anymore.
    – 0x0C4
    Aug 24, 2016 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .