I have a PHP application built on CodeIgniter. I have a large proportion of the website (the system folder to anyone who knows CodeIgniter) sitting below the Document Root.
Here is the Nginx conf for the website
server {
server_name www.domain.local;
root /var/www/html/domain/frontend;
include /etc/nginx/conf.d/ci_vhost;
}
Here is the the folder I am having issues trying to access /var/www/html/ci/2.0.2/system
With Apache, I never had issues accessing php files below the document root.
Does anyone know why i am experiencing this issue with Nginx?
Thanks.
The root directive specifies the root directory that will be used to search for a file. To obtain the path of a requested file, NGINX appends the request URI to the path specified by the root directive.
Using try_files means that you can test a sequence. If $uri doesn't exist, try $uri/ , if that doesn't exist try a fallback location.
You can access any folder on your server and just have to configure nginx accordingly using either the "alias" or "root" directives both of which can be defined multiple times within specific blocks.
server {
# Default root
root /var/www/html/domain/frontend;
location /abc
# Uses default root
...
}
location /xyz
# defines it's own root
root /var/www/some/folder;
...
}
location /123
# aliases to another folder
alias /etc/some/folder;
...
}
location /
# Uses default root
...
}
}
Read up on the difference between alias and root
For php, you will have to consider open_basedir restrictions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With