CONTINUE TO NGINX SECURING DOMAIN WITH SSL
Now that NGINX is installed and is now working with PHP, let’s secure your domain with SSL.
Let’s go through to setup PHP on Ubuntu
In your CLI window, enter the following command:
sudo apt-get install php-fpm php-mysql
From the CLI window, enter the following command:
sudo nano /etc/nginx/sites-available/default
index.php
as the first value of our index
directive so that files named index.php
are served, if available, when a directory is requested.server_name
directive to point to our server’s domain name or public IP address.location ~\.php$
location block, the included fastcgi-php.conf
snippet, and the socket associated with php-fpm
..htaccess
files using the same method. Nginx doesn’t process these files. If any of these files happen to find their way into the document root, they should not be served to visitors.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
In your CLI window, enter the following command:
sudo nginx -t
sudo service nginx restart
This allows us to test the NGINX Configuration. If no errors, proceed.
sudo nano /var/www/html/info.php
Then Paste the following:
<?php
phpinfo();
Save and Exit…
Then goto browser and enter:
http://server_domain_or_IP/info.php
If all is well, it will display a PHP info page.
Now that NGINX is installed and is now working with PHP, let’s secure your domain with SSL.