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

I am trying to port a website on php / mysql / apache on one server to another server.

The other server was a raw linux box on amazon ec2. I am not a advanced linux admin. I have some basic knowledge tough.

So i installed nginx and set doc root to /home/webroot/ . I setup php cgi server and started it on port 9000. Installed mysql and imported the dump. Created a FTP User called webroot with permissions to /home/webroot/ and added it to vsftpd to upload all the files to /home/webroot/.

Perfect.

I access subdomain.site.com and it resolves, but it returns a blank page. It is not interpreting index.php and other uploaded php files. How ever it is interpreting some of the new files i created. It is either shows blank page or DUMPS ENTIRE PHP CODE TO THE BROWSER.

I create an example test.php and populate it with some code to read request variables and print it. I access it from subdomain.site.com/test.php?id=2 and it does interpret it. It is also connecting to the database if i invoke it from the command line.

Why is it working with some files while not with some others. Is it a php error or a nginx error. Any ideas. Here is nginx.conf -

    server {
listen       80;
    server_name  sub.domain.com;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;

    location / {
        root   /home/webroot;
        index  index.html index.htm index.php;
    }

error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

# redirect server error pages to the static page /50x.html
    #
error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
#location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

# 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;
        fastcgi_param  SCRIPT_FILENAME  /home/webroot$fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
#location ~ /\.ht {
    #    deny  all;
    #}
}

# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;

}

any ideas ?

share|improve this question
    
Add root /home/webroot; directly under the server_name directive. FastCGI needs the root directive set outside the location block (as it should be!) to work properly. You may also want to turn on fastcgi_intercept_errors to get some more information about what (is not) happening. –  cyberx86 Dec 20 '11 at 2:22
1  
what is the value of short_open_tag in your php.ini? –  SaveTheRbtz Dec 20 '11 at 11:04
    
I agree with @SaveTheRbtz, it seems likely that short_open_tag is disabled and some of your scripts use the shorthand <? open tag instead of a full <?php tag. Can you check this, or if your not sure what this means, post a (small) file that is not working in your question? –  DaveRandom Dec 21 '11 at 20:59
add comment

1 Answer

I'm not an nginx or php expert but the nature of the behavior you describe tells me that either fastcgi isn't executing the php files, or that you may not have fastcgi running correctly on that server. I don't thing nginx will auto-start the fastcgi server, in which case you may be serving that content from nginx as static files.

Just a hunch though, hopefully it helps.

share|improve this answer
add comment

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.