This week I needed to install LimeSurvey on a subfolder of a Debian 8 server, that is running NGINX. As always, the biggest problem is preparing the right rewrite.
After doing lots of tests, and reading LimeSurvey documentation, my final configuration to run it on a subfolder is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
location ^~ /survey { access_log off; error_log /home/usuario/logs/survey.error.log; set $host_path "/home/usuario/public_html/survey"; root /home/usuario/public_html; try_files $uri /survey/index.php?$args; location ~ \.php { include /etc/nginx/fastcgi_params; fastcgi_pass php5-fpm; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } } |
Attention to the “fastcgi_pass php5-fpm;” detail, that in my case, represents a file in /etc/nginx/conf.d/php5-fpm.conf:
1 2 3 4 |
upstream php5-fpm{ server unix:/var/run/php5-fpm.sock; #server 127.0.0.1:9000; } |
This could be directly on location of the virtual host, but I prefer a external file to not have to repeat.
BONUS
If you don’t want index.php?r=foobar appearing on your URL, open /application/config/config.php of LimeSurvey and change two variables as below:
1 2 |
'urlFormat' => 'path' 'showScriptName' => false, |