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 ?
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 onfastcgi_intercept_errorsto get some more information about what (is not) happening. – cyberx86 Dec 20 '11 at 2:22short_open_tagin yourphp.ini? – SaveTheRbtz Dec 20 '11 at 11:04short_open_tagis disabled and some of your scripts use the shorthand<?open tag instead of a full<?phptag. 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