I have a Nginx server (1.6), with PHP-FPM on my local server.
I have multiple webapps in my "/var/www/" folder, like site01, site02…
My applications use CodeIgniter.
I want to have /var/www/site01 called on default location, and /var/www/site02 called when I go :
http://server/site02.
Here is my nginx default.conf :
server {
listen 80;
server_name localhost;
access_log off;
client_body_buffer_size 1M;
proxy_max_temp_file_size 0;
disable_symlinks off;
# Site 01
location / {
root /var/www/site01;
index index.html index.php index.htm;
try_files $uri $uri/ /index.php;
location = /index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 10000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 16K;
fastcgi_buffers 256 16k;
include fastcgi_params;
}
}
# Site 2
location /site02 {
root /var/www/;
index index.htm;
try_files $uri $uri/ /index.php;
location ~ ^/site02/index.php {
try_files $uri =404;
root /var/www/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 10000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 16K;
fastcgi_buffers 256 16k;
include /etc/nginx/fastcgi_params;
}
}
I have multiple errors, firstly, when I don't put "index.php" in my site02 URL, I have a 403 error. Then, I can't go any controller, it redirects me to /site01.
What is the best way to handle multiple PHP apps folders ? Why do I have these redirections ? Thanks.
Best Answer
First i see in your second site configuration :
CHANGE TO :
need index.php