Monday, May 29, 2017

Linux: Install PHP7 on Debian 8 Jessie wtih NGINX installed



1. Trigger this command vi /etc/apt/sources.list and add this lines to the repo/source list

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all



2. Update your system.

apt-get update



3. Get the gpg key and add to it to your system.

wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg




4. Install PHP7.0 and some PHP7.0 modules.

apt-get install php7.0 php7.0-fpm php7.0-mysql php7.0-cli php7.0-mcrypt



5. Backup the nginx config file.

mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak



6. Create a default nginx file.

vi /etc/nginx/sites-available/default



7. Add this lines of code.

server {
        listen       80;
        server_name  localhost;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;

        location / {
                try_files $uri $uri/ =404;
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;

        location = /50x.html {
                root /var/www/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }


}



8. Restart NGINX and PHP7.0

systemctl restart nginx
systemctl restart php7.0-fpm



9. Create a php file.

vi /var/www/html/info.php



<?php phpinfo(): ?>

10. Test the script in your preferred browser.



No comments:

Post a Comment