bolshi
Goto Top

Nach PHP7-Installation - PHP läuft nicht im Browsser

Hallo,

Beim Laden der phpinfo() im Browser wird PHP nur als Text ausgegeben.

Bislang lief PHP5.6 unter Ubuntu 14.04. Wir haben jetzt PHP7 installiert.

Nach aufrufen von "php -v" kommt im Terminal folgende Ausgabe:

root@server :/etc/apache2/mods-enabled# php -v
PHP 7.0.11-1+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.11-1+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies


Die Symlinks für php5.6.conf und php.5.6.load sind gelöscht.

Im Anschluss die Symlinks via

a2enmod php7.0 

erzeugt.

Abschließend

service apache2 restart

Im Seiten-Quelltext:

<?php
	phpinfo();

Content-Key: 315709

Url: https://administrator.de/contentid/315709

Ausgedruckt am: 29.03.2024 um 00:03 Uhr

Mitglied: Xerebus
Xerebus 20.09.2016 um 12:26:54 Uhr
Goto Top
Im Seiten-Quelltext vergessen?
?>
Mitglied: bolshi
bolshi 20.09.2016 um 13:02:38 Uhr
Goto Top
Hier die Lösung:

First add some prerequesites and add the PHP7 repository:

apt-get update
apt-get install software-properties-common python-software-properties
add-apt-repository ppa:ondrej/php-7.0

Then install the actual PHP packages (remove those form the list that you do not need):

apt-get install php7.0-fpm php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-mysql php7.0-phpdbg php7.0-dbg php7.0-gd php7.0-imap php7.0-ldap php7.0-pgsql php7.0-pspell php7.0-recode php7.0-snmp php7.0-tidy php7.0-dev php7.0-intl php7.0-gd php7.0-curl

Then install Apache worker:

apt-get install apache2-mpm-worker


Now let's modify the apache configuration, so that you're using PHP7-FPM. Edit /etc/apache2/sites-enabled/000-default.conf and add the following block before </VirtualHost>:
DirectoryIndex index.php
<LocationMatch "^(.*\.php)$">  
     ProxyPass fcgi://127.0.0.1:9000/var/www/html
</LocationMatch>

Now let's activate the proxy fcgi module and restart Apache:
a2enmod proxy_fcgi
service apache2 restart


Next in /etc/php/7.0/fpm/pool.d/www.conf comment the line containing the socket and add the line below as indicated:
; listen = /run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000

Finally restart PHP7-FPM:
service php7.0-fpm restart

Add an info.php to your webroot and paste the following:
<?php
echo phpinfo();


And point the browser to your webserver and you're ready to go! You should see the phpinfo page.