I'm installing Wordpress on my Ubuntu server running nginx. The installation went pretty smoothly (following Installing LEMP and Installing Wordpress tutorials - took me through mysql, php5-fpm and wordpress setup), and seems to mostly work. I can view the Wordpress admin page, create blog posts and even view those posts. But when I try to access the homepage of my blog (eg. index.php), nginx serves the file as a download rather than executing it. I have already tried the configurations in Nginx serves .php files as downloads, instead of executing them to no avail.
Here is my virtual server file:
server {
listen 80;
server_name my.domain.com;
root /my/wordpress/home/dir;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.php?$args;
rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ redirect;
if (-e $request_filename) {
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 break;
}
rewrite ^/([_0-9a-zA-Z-]+/)?(.*\.php)$ /$2 break;
rewrite ^(.*)$ /index.php break;
}
}
And nginx.conf:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
I removed commented lines for clarity. sudo nginx -t
reports no errors.
How can I get index.php to execute instead of being served as a download? Thanks for your help.
Edit: Looks like it was a browser caching issue. I tried deleting cached data from the past 24 hours but it didn't change anything. After deleting everything it now loads properly instead of downloading. It also loads on other browsers/computers just fine.