I'm moving my wordpress blog from Apache to Nginx. I've tried multiple tutorials to get permalinks working but nothing is working for me. My website structure is like this:
main site -> www.localhost.com wordpress blog -> www.localhost.com/blog Website is in /var/www/html and wordpress is installed in /var/www/html/blog
I've read multiple articles and watched multiple videos but nothing seems to be working. Please let me know where I'm going wrong.
I've defined two server blocks in /etc/nginx/sites-available/default one for main site and one for the blog.
# Default server configuration # server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; charset utf-8; error_page 404 /404.php; location /article { rewrite ^/article.* / redirect; } #location / { # try_files $uri $uri/ /loadpage.php?$args; #} location ~ \.html$ { try_files $uri /courses/index.php?$args; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php7.0-fpm: fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } server { listen 80; listen [::]:80; root /var/www/html/blog; index index.php index.html index.htm; server_name example.com www.example.com; location /blog/ { try_files $uri $uri/ /blog/index.php?$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; # fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; #Ubuntu 17.10 fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; #Ubuntu 17.04 include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }