Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Cannot get Nginx to work with my WordPress

$
0
0
Hello all

A bit of background information. I have a CentOS 7 VPS. I installed the LAMP stack on it and everything was fine, all working well, but heard how Nginx is faster, so I decided to move my sites over to Nginx. I uninstall Apache and installed Nginx.

I did not imagine things would be so complex. I have followed various instructions around the web, but nothing seems to work for me. Right now, only the homepage to my website is working, everything else doesn't. Even the homepage doesn't show certain images, not sure why.

Here is my server block for the Wordpress website:

server {
listen *:80;
server_name nativeleaf.co.uk www.nativeleaf.co.uk;

expires 86400s;
add_header Pragma public;
add_header Cache-Control "max-age=86400, public, must-revalidate, proxy-revalidate";

error_page 404 /404.html;
location /404.html {
internal;
}

error_page 403 = 404;

location ~ /(\.|wp-config.php|readme.html|licence.txt) {
return 404;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~* ^.+\.(css|js)$ {
rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
expires 31536000s;
access_log off;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "max-age=31536000, public";
}

error_log /var/log/nginx/nativeleaf.co.uk-error.log;
access_log /var/log/nginx/nativeleaf.co.uk-access.log;

root /var/www/html/nativeleaf.co.uk;

location / {
index index.php index.html index.htm;
}

# get friendly url links working
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}

# pass all PHP files through php-fpm
location ~ \.php$ {

try_files $uri =404;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/wordpress-user/techarena51.com$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}

# deny all apache .htaccess or .htpasswd files
location ~ /\.ht
{
deny all;
}

# Deny access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}

I am using php-fpm for handling the php, I've read that I must do this because Nginx is different from Apache and has to delegate the PHP stuff to either fastcgi or php-fpm, correct me if I'm wrong.

Any help would be greatly appreciated.

Thank you

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>