Opening ZF3 skeleton-application shows only source code but not the web page

235 views Asked by At

I setup a new development machine with my Mac. Now I installed the zend framework skeleton-application.

When I open the url, it will show me the source code of index.php into my browser and not the web site.

Into /etc/apache2/httpd-vhosts.conf I added this:

<VirtualHost *:80>
    ServerName test.dev
    ServerAdmin [email protected]
    DocumentRoot "/Users/myname/Projekte/web/test/public/"
    SetEnv APPLICATION_ENV "development"

    <Directory "/Users/myname/Projekte/web/test/public/" >
        DirectoryIndex index.php
        AllowOverride All
        Require all granted
    </Directory>

ErrorLog "/private/var/log/apache2/test.dev-error_log"
CustomLog "/private/var/log/apache2/test.dev-access_log" common

What can I do to solve this problem? Do I need a .htaccess at into my public directory?

Thanks for help.

1

There are 1 answers

0
Thomas Dutrion On

Just to write a proper answer as the problem has been solved in comments.

So the problem was that an http request got back the source code as a response. Obviously, this is not a Zend Framework related question but rather a server configuration issue.

In order to properly diagnose the problem, one could use the most simple php code and directly try to access the script, hence dismissing the framework related issue. <?php phpinfo(); is a good test for instance.

Apache has two ways to make php interpreted: php-fpm and mod_php. One of those at least must be configured in order for Apache to pass the files to the interpreter.

In this specific case, the module was installed on the machine but not loaded in the configuration file, which has been done using the following line in apache config file:

LoadModule php5_module libexec/apache2/libphp5.so