Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When browsing to a page on the site the page is being download instead of running Nginx Config -

    user www-data www-data;
worker_processes  4;
events {
    worker_connections  2048;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log  off;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     off;
    keepalive_timeout  10;
    gzip  on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root  /home/bil/public_html/webiste.net/public/;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
include /usr/local/nginx/sites-enabled/*;

    }

Virtual Site config -

server {
            listen   80;
            server_name  localhost;
            rewrite ^/(.*) http://webiste.net/$1 permanent;
       }
server {
            listen   80;
            server_name localhost;
            access_log /home/bil/public_html/webiste.net/log/access.log;
            error_log /home/bil/public_html/webiste.net/log/error.log;
            location /  {
                        root  /home/bil/public_html/webiste.net/public/;
                        index  index.php index.html;
                        }
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$
                                {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            include /usr/local/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /home/bil/public_html/webiste.net/public/$fastcgi_script_name;
                        }

       }`
share|improve this question

2 Answers 2

I don't think your server_name's are reflecting what you want to do. The configuration is fine, but all three "localhost" mean the first one catches. There is no php location in the first one.

share|improve this answer

Replace your rewrite rule with below

rewrite ^/(.*) http://webiste.net/$1 last;

I Hope this will help, Thanks

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.