1

I've got a problem to use phpbrew with my Xubuntu 16.04 x64 and apache2. I used it on xubuntu 14.04 without problem but now i'm really stuck :/ I will try to explain it with all informations needed.

All went fluently during installation of each version with that command line

phpbrew install 7.0.16 +default +mysql +pdo +apxs2=/usr/bin/apxs2 +mb

When i switch php version it's ok and i see the right version when i do

php -v

but i can see it's changing only CLI version of php

PHP 7.0.16 (cli) (built: Feb 28 2017 17:25:51) ( NTS )

If i take a look in .phpbrew/php i can see a folder for each versions of php i've installed and when i look in /etc/apache2/mods-available/ i've got phpX.X.load pointing the corresponding libphpX.X.XX.so in the folder /usr/lib/apache2/modules/ . All libphpX.X.XX.so are present in the folder. When i restart apache, i've got no errors.

I precise that i've installed phpbrew with that requirements (https://coderwall.com/p/hguzxa/phpbrew-on-ubuntu-16-04-php7)

So now i'm just trying that simple php line in a index.html file

<?php echo '<h1>Hello, world!</h1>';?>

But it seems apache can't interpret php because it appears like that

Hello, world!';?>

Finally, when i look the file /var/log/apache2/error.log, there is no error info inside.

Thank you in advance if you can help me for that!

mrDinkelman
  • 450
  • 1
  • 10
  • 16
Siick
  • 361
  • 4
  • 20

1 Answers1

1

Your browser prints for you

Hello, world!';?>

because your Apache server is misconfigured and can't handle PHP scripts. This behavior from browser was confused you, because you're using valid HTML tag inside your string. Just try to print this string

<?php echo 'Hello, world!';?>

and there is nothing in browser window. But, if you open page source code, you will see that your PHP string comes into DOM document as raw value, without processed PHP tags.

For resolving this info just try to add missing config for Apache:

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

Place the next content in this file

<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_php7.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>

Now, you tell Apache with config how it can process PHP scripts. So, now just run

a2enconf php
systemctl restart apache2.service

You can review Apache running state with

systemctl status apache2.service

Now, don't forget to check that your test script named like something-to-test.php (not html) and run it in you browser.

Enjoy your processed PHP script and happy coding ;)

mrDinkelman
  • 450
  • 1
  • 10
  • 16
  • 1
    the answer is here -> "Now, don't forget to check that your test script named like something-to-test.php (not html) and run it in you browser." Noobish error -_-' – Siick Jan 31 '18 at 09:54