1

Ubuntu 12.04

Apache2 is installed

# apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built:   Mar 19 2014 21:11:49

PHP is installed

# php --version
PHP 5.4.6-1ubuntu1.8 (cli) (built: Apr  4 2014 01:28:36)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

PHP module is installed and enabled

# a2enmod php5
Module php5 already enabled

php5.conf contains SetHandler directive

<IfModule mod_php5.c>
    <FilesMatch ".+\.ph(p[345]?|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
        Order Deny,Allow
        Deny from all
    </FilesMatch>
    # Deny access to files without filename (e.g. '.php')
    <FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
        Order Deny,Allow
        Deny from all
    </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_value engine Off
        </Directory>
    </IfModule>
</IfModule>

but my file /var/www/wwwuser/data/domain.com/info.php

<?php phpinfo(); ?>

is not executed - it's source code returned. Why?

4
  • Look at this and this. Hope they help. Commented Jun 29, 2014 at 19:08
  • @Idris I already googled it. No success. Commented Jun 29, 2014 at 19:15
  • Which URL do you use to access the file? Are there virtual hosts defined that may interfere with your module definition? Commented Jun 29, 2014 at 21:17
  • @TeTeT I use mydomain.com/info.php to access the file. Other vhosts exist by there are no collisions with them. Commented Jun 29, 2014 at 21:22

2 Answers 2

4

Try sudo apt-get install libapache2-mod-php7.2 && sudo service apache2 restart Well you might have another version of php, so refer to your php version. Worked for me zend run perfectly

Sign up to request clarification or add additional context in comments.

Comments

3

This question is a year old and it's probably too late for the OP, but there is no accepted answer and I stumbled here from Google. I was dealing with a very similar problem, and perhaps my solution will be of use to somebody in the future:

There is a PHP directive in php.ini:

short_open_tag = Off

If this is Off, then PHP will ignore <? ?> tags, as it requires <?php ?>.

So in my case, the problem was my test script:

<? phpinfo(); ?>

Solution is to change the tags to <?php or just update the INI file to read short_open_tag = On.

2 Comments

This answer was a life saver, and I would never have thought of it. For context, they changed this from On to Off as the default between Ubuntu 12.04 and 14.04
Please note, that it is highly discouraged to use short tags anymore as the RFC (wiki.php.net/rfc/deprecate_php_short_tags_v2) is deprecating it in PHP 8.0 and will be dropped in PHP 9.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.