Hi there I am trying to load balance my website between 2 servers.
I have set them both up to mirror each other
But they are a forum and using PHP ???
This is the code I have but it will only use one site.
It only uses the 127.0.0.1 local address and will not contact my other
PHP server ?
I opened the port 9000 on both machines via iptables ???
upstream newsite {
server 127.0.0.1:9000;
server 15.82.114.196:9000;
}
server
{
listen 80;
server_name thissite.com;
index index.html index.htm index.php;
root /data0/htdocs/www/forum;
location ~ .*\.php?$
{
include fcgi.conf;
fastcgi_pass newsite;
fastcgi_index index.php;
}
Thank you very much
Posted at Nginx Forum:
upstream newsite {
server 127.0.0.1:9000;
server 15.82.114.196:9001;
}
server
{
listen 80;
server_name thissite.com;
index index.html index.htm index.php;
root /data0/htdocs/www/forum;
location ~ .*\.php?$
{
include fcgi.conf;
fastcgi_pass newsite;
fastcgi_index index.php;
}
I think this might be a permission thing ? but I have no idea how to fix
it
Still getting the:
no input file specified
Not sure how to make the main server work with my other server ?
Thank you very much
Posted at Nginx Forum:
Check the script_filename in fcgi.conf (post it) it should be in caps
too but I’m on my iPhone 
If that looks okay then make sure the file is accessable in the right
location on the remote hosts. Cause that’s how PHP throws a 404 (that
is so annoying)
Jerome maybe php-fpm sapi could be patched to throw a 404 header and
something resembling a proper error? 
I managed to get it working KIND OFF lol.
I edited the php file
nano /etc/rc.d/init.d/php_cgi
There you can set the IP address and the port for php and it will start
with your ip and port of choice.
I now have another problem 
This is my code and it is load balancing 50% to each server now 
but I get 50% of pages white with the words:
no input file specified
Thank you for any help
Posted at Nginx Forum:
Hi Mike
I do not have a fcgi.conf ?
I have a spawn-fcgi
/usr/bin/spawn-fcgi
Thanks Mike
Mick
Posted at Nginx Forum:
Sorry Mike lol
Could it be that one server is running fpm and the other is cgi ?
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS 200;
Posted at Nginx Forum:
i know that typically the error is due to this not being defined right:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
are you sure that on the remote server that
/data0/htdocs/www/forum/path/to/file.php exists?
Must they be identical on both machines ?
Because I have it running, if I go to the IP address.
IE
http://newserverip
Then I can view the forums.
So should I make the home directories exactly the same on both machines
?
Regards
Mick
Posted at Nginx Forum:
the SCRIPT_FILENAME being passed is from the nginx machine to the PHP
fastcgi engines
PHP is taking that and saying “okay, i need to execute this pathname as
PHP”
so yes, if it’s not the same, you’ll have issues. 
there’s probably some other creative ways to mangle it per machine but
for sanity you should keep things in sync anyway. a simple stack is a
happy stack.
Yeah thanks mike that worked.
The slave server is very slow 
Dunno why its going so slow but thanks for all your help
Mick
Posted at Nginx Forum:
Thank you very much for your time MIKE 
You are right it was not worth the hassle of doing it this way 
I have decided to use my 4 servers like this
- Private server (not open to public) - MYSQL
- Weserver - PHP
- Image Server
- attachment server.
This way I can reduce load of attachments and images and leave the PHP
to the 2) Webserver.
Thanks Mike I still need help but I think I better start a new thread
with new parameters.
Cheers for the help
Mickie
Posted at Nginx Forum:
Nginx can handle both php and static assets easily on the same
machine. No need to have them on separate machines. I think you need
some architecture help 
well it looks like you’re using a public IP, which means it’s over the
WAN, which you should make sure is firewalled (iptables or something)
so only the webserver(s) can connect, and depending on the latency
between the machines it might be so slow that it doesn’t make sense.
Thanks Mike you are probably right but I have high amounts of concurrent
users on my site at any one time… from 500 - 800.
I found fine tuning xcache, and memcache today has really helped out my
server the pages are zipping open now.
But I still want to offset the images and memcached to my new server…
with nginx.
When you are using proxy_pass do you have to use network (local) ip’s or
should you use public ip’s ?
Thank you
Mick
Posted at Nginx Forum:
Always use private connections where you can. For php fastcgi engines,
mysql, memcached, everything.