Closed samirfor closed 8 years ago
root
should be public
directory.css
and images
should be in public
directory.Of course. This would work if I my project worked with codeigniter as the main framework.
However, I need codeigniter installed in a subfolder and served as /api
and angularjs actually is the main framework.
angularjs actually is the main framework.
It does not matter. In any case, you should put only index.php
in your public accessible directory.
It is because to avoid direct accesses to the files that does not needed to be accessed. This is a security principle (minimal privilege).
What you need to do is to map http://example.com/api/
to the api/public/
directory in your Nginx config, not to put all files in docroot.
See http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
Yes. You're right. I did work.
See my dirtree:
.
├── bower.json
├── CHANGELOG.md
├── codeigniter
│ ├── application
│ │ ├── cache
│ │ ├── config
│ │ ├── controllers
│ │ ├── core
│ │ ├── helpers
│ │ ├── hooks
│ │ ├── index.html
│ │ ├── language
│ │ ├── libraries
│ │ ├── logs
│ │ ├── models
│ │ ├── third_party
│ │ └── views
│ ├── bin
│ │ ├── check-diff.sh
│ │ ├── install.php
│ │ ├── my-codeigniter.sh
│ │ ├── router.php
│ │ └── server.sh
│ ├── composer.json
│ ├── composer.lock
│ ├── public # document_root
│ │ ├── css # moved
│ │ ├── images # moved
│ │ ├── index.html # moved
│ │ ├── index.php
│ │ ├── js # moved
│ │ ├── lib # moved
│ │ ├── scripts # moved
│ │ └── views # moved
│ ├── README.md
│ └── vendor # composer
│ ├── autoload.php
│ ├── codeigniter
│ ├── composer
│ └── mikey179
└── README.md
my conf:
server {
listen 80;
listen [::]:80 ipv6only=on;
#server_name localhost
root /var/www/myproj/codeigniter/public;
index index.html index.php index.htm;
location / {
try_files $uri $uri/ /index.php?$request_uri;
}
location ~* \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_param CI_ENV development;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_read_timeout 150;
}
}
Good to hear!
Thanks for your superb help.
I can not make it work in nginx.
My tree of files:
See my settings:
/etc/nginx/sites-enabled/myproj.conf
/etc/nginx/fastcgi_params
(untouched - ubuntu's default)I tried some variations on the
location /api/
block (rewrite, alias, root, try_files) unsuccessful.