Previously we talked about upgrading to Ubuntu 16.04 LTS from Ubuntu 14.04 LTS. For the past many years, all are used with guides like this for installing WordPress on Ubuntu 14.04 with Nginx PHP 5 FPM.
There are Differences in Paths in Nginx PHP 7 FPM Ubuntu 16.04 vs 14.04 PHP 5. We suggest to use ppa:ondrej/php
(older ppa:ondrej/php-php7.0
) for PHP 7 too instead of Ubuntu’s default.
Paths in Nginx PHP 7 FPM Ubuntu 16.04 vs 14.04 PHP 5 : Intended Audience
Quick Note is For Various Reasons. We will upgrade our guides linked from official website’s documentations to make compatible with Ubuntu 14.04 vs Ubuntu 14.04 LTS. Purpose of this article is for helping in backward-forward compatibility and easy guide for who wants to upgrade to Nginx PHP 7 FPM on Ubuntu 16.04 LTS with the old stuffs. There are too many changes both from the OS level and PHP package. There are not many guides to troubleshoot.
Ubuntu 16.04 comes with php 7.0 and some php applications might still fail with php 7.0 . Therefore, in some cases, it might be sensible to have php 5.x. If you want so, add ppa:ondrej/php
repo and do these :
---
1 2 3 4 5 6 | sudo add-apt-repository ppa:ondrej/php apt-get purge php5-common sudo apt-get update sudo apt-get install php5.6 # example of full replacement # sudo apt-get install php5.6 php5.6-mysql php5-common php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mcrypt php5.6-xml php5.6-xmlrpc xcache |
As all packaged depend on php5-common
, so simply apt-get purge php5-common
will purge all php5 packages from your system.
If you need help or has questions, ask package maintainer ondrej
on StackExchange :
1 | https://askubuntu.com/users/137741/oerdnj |
ondrej
‘s original name is Ondřej Surý and uses @oerdnj
handle on Twitter. Here are official issues and incompatibilities :
1 2 | http://php.net/manual/en/migration70.incompatible.php http://php.net/manual/en/migration70.php |
Paths in Nginx PHP 7 FPM Ubuntu 16.04 vs 14.04 PHP 5
Package Nginx, Nginx-Plus, Nginx-Extras
Nothing to mention.
Package Percona MySQL
The mysql extension is not available anymore, so if you never switched to PDO
or mysqli
this is going to be a problem. mysql_
function calls with mysqli_
to solves that.
Package PHP FPM
Installation of PHP-FPM :
1 | apt-get -y install php7.0-fpm |
The binaries are installed in /usr/local/php7/sbin/php-fpm
. Configuration files are in /usr/local/php7/etc
. If you try to find memcached
‘s ini file, this will be the path :
1 | /etc/php/7.0/fpm/conf.d/20-memcached.ini |
PHP-FPM is a daemon process with the init script php7.0-fpm
that runs a FastCGI server on the socket :
1 | /run/php/php7.0-fpm.sock |
Hence, our common PHP5-FPM UNIX socket needs adjustment for Nginx :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | server { listen 80 default_server; root /usr/share/nginx/html; index index.html index.htm index.php; server_name localhost; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } |
Main php-fpm
configuration file :
1 | /etc/php/7.0/fpm/php.ini |
In the same way, www.conf
file is here :
1 | /etc/php/7.0/fpm/pool.d/www.conf |
Package Memcached
php-memcached
package is built into ppa:ondrej/php-php7.0
for php7, install it via the package php-memcached
.
Package XCache
Probably not suggestible to use. Use apt-cache search php7.0
to find your older packages other than XCache.