Install nginx and php7 on ubuntu 16.04

First of all get all updates.

sudo apt-get update

Install nginx server

sudo apt-get install nginx

Now open http://server_domain_or_IP You should see the default page of nginx.

The default directory is /var/www/html/

Now lets install php for processing

sudo apt-get install php-fpm php-mysql

Uncomment the follwoing lines in /etc/nginx/sites-available/default

 location ~ \.php$ {

                include snippets/fastcgi-php.conf;


        #       # With php7.0-cgi alone:

        #       fastcgi_pass;

        #       # With php7.0-fpm:

                fastcgi_pass unix:/run/php/php7.0-fpm.sock;



index index.html index.htm index.nginx-debian.html;


index index.php index.html index.htm index.nginx-debian.html;

Restart nginx

service nginx restart

Now your nginx server is ready to execute php script.

Note : If you want to execute sql query through php script then use mysli_query() instead of mysql_auery().


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s