I am new user of nginx, I installed it as replace of apache on cpanel
server for one very busy site.
I installed it to default folder /usr/local/nginx and setup it working
with php fastcgi spawn, but it only works from nginx default root i.e.
only from /usr/local/nginx/html
I need its root to be changed for different vhosts paths like
/home/user/public_html but look like all my commands like root
/home/user/public_html; are some why ignored by nginx and it is always
trying to run files from /usr/local/nginx/html
I checked in error log - and there are no errors displayed - only in
access log I see message that file not found 404 error.
You can do one of two things, both quite straight forward. First, you
can
build it with the --prefix set to something other than /usr/local/nginx
or
you can supply a full-path with your configurations “root” directive.
You should have in your config somewhere a line like this:
root html;
Changing it like this should help:
root /var/www;
Of course you should replace /var/www with the proper root. Also, for
sub-locations that need a separate root, you may find the “alias”
directive
useful, like so:
server {
listen 80;
root /var/www;
location /funstuff {
alias /home/me/funstuff;
}
}
Actuall now I found this problem is only happens with my php files.
For other non php files all paths are working ok.
For example this config is working properly:
location / {
index index.html index.php;
root /home/user/public_html;
}
On this config all non-php files are served correctly from correct
locations, but php files are getting error 404 file no found.
But when I setup nginx default path as /usr/local/nginx/html - then even
php working properly.
On Wed, Feb 25, 2009 at 02:12:30PM -0800, Merlin wrote:
root /var/www;
Of course you should replace /var/www with the proper root. Also, for
sub-locations that need a separate root, you may find the “alias” directive
useful, like so:
server {
listen 80;
root /var/www;
location /funstuff {
alias /home/me/funstuff;
For this case it’s better to use just “root”:
location /funstuff {
root /home/me;
The “alias” is required if you need to replace location part.
On Wed, Feb 25, 2009 at 11:38:22PM +0100, Y. Yaax wrote:
location ~ .php$ {
php working properly.
So what can be problem with this fastcgi config?
Where you .php files are located ?
This configuraiton try to execute them as
/home/user/public_html/…
php files are located in this folder /home/user/public_html/ - in fact
they are served correctly by apache from same folder on another port.
But fastcgi cannot find them, there…
On Thu, Feb 26, 2009 at 11:11:52AM +0100, Y. Yaax wrote:
/home/user/public_html/…
php files are located in this folder /home/user/public_html/ - in fact
they are served correctly by apache from same folder on another port.
But fastcgi cannot find them, there…
On Thu, Feb 26, 2009 at 11:11:52AM +0100, Y. Yaax wrote:
/home/user/public_html/…
php files are located in this folder /home/user/public_html/ - in fact
they are served correctly by apache from same folder on another port.
But fastcgi cannot find them, there…
$document_root$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME
/home/user/public_html$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}
I tried both ways fastcgi_param SCRIPT_FILENAME
/home/user/public_html$fastcgi_script_name; and fastcgi_param
SCRIPT_FILENAME $document_root$fastcgi_script_name;
Ok, finally I succeed to run php correctly, for this I was required to
replace spawn fcgi with php-fpm. It look like nginx works better for
php-fpm then for spawn-fcgi, at least config was easier.
$document_root$fastcgi_script_name; #fastcgi_param SCRIPT_FILENAME
/home/user/public_html$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}
I tried both ways fastcgi_param SCRIPT_FILENAME
/home/user/public_html$fastcgi_script_name; and fastcgi_param
SCRIPT_FILENAME $document_root$fastcgi_script_name;
both ways have same error file not found.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.