First time, i will install nginx-extras (extended version of nginx):
root@vm02:~# apt-get install nginx-extras
Adding dotdeb to apt sources list:
root@vm02:~# echo "deb http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list
Installing curl and adding dotdeb key for apt:
root@vm02:~# apt-get install curl
root@vm02:~# curl http://www.dotdeb.org/dotdeb.gpg | apt-key add -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5299 100 5299 0 0 34043 0 --:--:-- --:--:-- --:--:-- 34187
OK
Apt update and php7 installation:
root@vm02:~# apt-get update root@vm02:~# apt-get install php7.0 php7.0-fpm php7.0-cli php7.0-curl php7.0-gd php7.0-geoip php7.0-intl php7.0-json root@vm02:~# apt-get install php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-xsl php7.0-zip
Testing php7 from CLI:
root@vm02:~# php -v
PHP 7.0.13-1~dotdeb+8.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.13-1~dotdeb+8.1, Copyright (c) 1999-2016, by Zend Technologies
root@vm02:~#
I will remove the default vhost configuration from nginx and i will write a new one:
root@vm02:~# cd /etc/nginx/sites-enabled/ root@vm02:/etc/nginx/sites-enabled# rm default root@vm02:/etc/nginx/sites-enabled# nano default
‘default’ file content (write and save)
server {
listen 80;
server_name _;
root /var/www;
# Main location
location / {
root /var/www;
index index.php index.html;
}
# Pass php files to php-fpm unix socket
location ~ .php$ {
fastcgi_keep_conn on;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
# Static files
location ~* ^.+.(jpg|jpeg|gif|png|svg|ico|css|less|xml|html?|swf|js|ttf)$ {
root /var/www;
expires 10y;
}
}
Reload nginx and let’s test over web (point your browser at your ip address):
root@vm02:/etc/nginx/sites-enabled# /etc/init.d/nginx reload [ ok ] Reloading nginx configuration (via systemctl): nginx.service. root@vm02:/etc/nginx/sites-enabled# cd /var/www/ root@vm02:/var/www# echo "" > index.php