Hi .
How can I change the root directory in nginx??
Now my root directory is /usr/share/nginx/html.
I want change it, like ~/web
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229128,229128#msg-229128
Hi .
How can I change the root directory in nginx??
Now my root directory is /usr/share/nginx/html.
I want change it, like ~/web
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229128,229128#msg-229128
On Tue, Jul 31, 2012 at 05:08:29AM -0400, sayres wrote:
Hi there,
How can I change the root directory in nginx??
Now my root directory is /usr/share/nginx/html.
I want change it, like ~/web
Probably: put “root /home/user/web;” in the server{} block that you
care about.
Francis D. [email protected]
Thisis my defualt config:
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
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$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location /phpMyAdmin {
alias /usr/share/phpMyAdmin;
index index.php index.html index.htm;
}
location ~ /phpMyAdmin/.*.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/$uri;
fastcgi_intercept_errors on;
include fastcgi_params;
}
location ~ .php$ {
try_files $uri =404;
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location ~ /.ht {
deny all;
}
}
Which part I must add /home/user/web??
Sorry I’m newcomer in nginx and my english is very bad.
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229128,229185#msg-229185
Sorry dude
Can you explain by example???
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229128,229214#msg-229214
Sorry dude
Can you explain by example???
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229128,229215#msg-229215
On Wed, Aug 01, 2012 at 07:02:44AM -0400, sayres wrote:
Hi there,
Every location{} can have a “root” directive.
If a location has a “root” directive, then that is the root for requests
handled in that location.
If a location does not have a “root” directive, then the “root”
directive
from the server{} level applies.
If the server{} does not have a “root” directive, then the “root”
directive from the http{} level applies.
If http{} does not have a “root” directive, then the compile-time
default applies.
Which part I must add /home/user/web??
I suggest that you remove all of the current “root” directives, and add
your one into the server{} block.
Francis D. [email protected]
On Wed, Aug 01, 2012 at 05:09:39PM -0400, sayres wrote:
Can you explain by example???
In your current config file, add
root /usr/share/nginx/html;
immediately after
server {
and delete the other four mentions of
root /usr/share/nginx/html;
that are inside different location{} blocks.
Your server should be effectively the same as it was
To change to a new root directory, change the one line that you added.
Francis D. [email protected]
This is my new current config:
############## Document Root #######################
root /home/sayres/web;
server {
############### General Settings ####################
listen 80;
server_name _;
location / {
index index.html index.htm index.php;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
############## PHPMyAdmin #######################
location /phpMyAdmin {
alias /usr/share/phpMyAdmin;
index index.php index.html index.htm;
}
location ~ /phpMyAdmin/.*.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/$uri;
fastcgi_intercept_errors on;
include fastcgi_params;
}
############## PHP #################################
location ~ .php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
[[email protected] sayres]# ls -l /home/sayres/
total 96
drwxrwxrwx. 1 root root 4096 Aug 3 01:14 D
drwxr-xr-x. 2 sayres sayres 4096 Jul 2 11:42 Desktop
drwxr-xr-x. 2 sayres sayres 4096 Jul 21 13:28 Documents
drwxr-xr-x. 3 sayres sayres 4096 Jul 3 14:16 Downloads
drwxrwxr-x. 3 sayres sayres 36864 Jul 5 20:26 localrepo
drwxrwxr-x. 2 sayres sayres 4096 Jul 21 14:03 logs
drwxr-xr-x. 2 sayres sayres 4096 Jul 2 11:41 Music
-rw-r–r--. 1 root root 9678 Jul 31 11:11 php-fpm.txt
drwxr-xr-x. 3 sayres sayres 4096 Jul 21 13:24 Pictures
drwxr-xr-x. 2 sayres sayres 4096 Jul 2 11:41 Public
drwxrwxr-x. 4 sayres sayres 4096 Jul 21 13:25 simpleconky
drwxr-xr-x. 2 sayres sayres 4096 Jul 31 20:00 Templates
drwxr-xr-x. 2 sayres sayres 4096 Jul 5 20:57 Videos
drwxrwxrwx. 3 sayres sayres 4096 Aug 3 14:44 web
after that and restart nginx service :
systemctl restart nginx.service
It seems that everything currect.
Thanks dude.
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,229128,229283#msg-229283
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs