Skip to content

Instantly share code, notes, and snippets.

@Pelirrojo
Last active August 15, 2017 18:45
Show Gist options
  • Save Pelirrojo/c5fd89a3233b3711b9184cfc103a5885 to your computer and use it in GitHub Desktop.
Save Pelirrojo/c5fd89a3233b3711b9184cfc103a5885 to your computer and use it in GitHub Desktop.
NGINX Configuration for Wordpress@4.8.1 SITE with SSL, http->https redirection
# Based in:
# https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04
# https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-16-04
# HTTP Config
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name www.yoursite.com;
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS Config
server {
listen 443 http2 ssl;
ssl_certificate /etc/ssl/path/to/certificate.cer;
ssl_certificate_key /etc/ssl/path/to/certificate.key;
# To generate it use: openssl dhparam -out /etc/ssl/path/to/certificate.dhparam.pem 2048
ssl_dhparam /etc/ssl/path/to/certificate.dhparam.pem;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name www.yoursite.com;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
@Pelirrojo
Copy link
Author

Only replace:

Tested on AWS EC2 Ubuntu 16.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment