Avice for my vhost configuration

Mik J mikydevel at yahoo.fr
Tue Aug 6 19:40:47 UTC 2013


Hello, Thank you both for your answer.

I did read the page http://nginx.org/en/docs/ngx_core_module.html#include but I sometimes get confused how to put things in order exactly.

I removed the root stanza in the location block.

As for fastcgi_params I already have the line
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

which looks like the one you wrote
fastcgi_param  SCRIPT_FILENAME      $document_root$fastcgi_script_name;
in your my_fastcgi_params

What is the difference between those two ? I didn't see SCRIPT_NAME in the HttpFastcgiModule documentation whereas SCRIPT_FILENAME is defined by "Parameter SCRIPT_FILENAME is used by PHP for determining the name of script to execute"

Also, where should I put my include files ? It seems that /etc/nginx is the default location. Or you put them in another directory ?

Cheers




>________________________________
> De : wishmaster <artemrts at ukr.net>
>À : nginx at nginx.org 
>Cc : "nginx at nginx.org" <nginx at nginx.org> 
>Envoyé le : Mardi 6 août 2013 10h10
>Objet : Re: Avice for my vhost configuration
> 
>
>--- Original message ---
>From: "Mik J" <mikydevel at yahoo.fr>
>Date: 6 August 2013, 00:44:37
>
>> Hello,
>> 
>> I plan to configure my nginx server with a couple of vhosts.
>> 
>> For each of them I want:
>> 
>> - to use php
>> 
>> - deny access begining by a dot
>> 
>> - not logging access to favicon
>> 
>> So my configuration would look like that
>> 
>> server {
>> ...
>> location ~ \.php$ {
>> root           /var/www/htdocs/sites/expertinet;
>> fastcgi_pass   unix:/tmp/php.sock;
>> #            fastcgi_pass   127.0.0.1:9000;
>> fastcgi_index  index.php;
>> fastcgi_param  SCRIPT_FILENAME      $document_root$fastcgi_script_name;
>> include       
>> fastcgi_params;
>> }
>> 
>> location ~ /\. {
>> access_log off;
>> log_not_found off;
>> deny all;
>> }
>> 
>> location = /favicon.ico {
>> return 204;
>> access_log off;
>> log_not_found off;
>> expires 30d;
>> }
>> 
>> }
>> This in each of my virtual host configuration. This is very redundant.
>> 
>> For example if I want to use tcp socket for fastcgi_pass, I need to edit every single vhost configuration.
>> 
>> What are you advices to avoid this ? What is the recommended practice ?
>> 
>> Someone adviced my to use include... Could you show me an example ?
>  
>      You must read docs. http://nginx.org/en/docs/ngx_core_module.html#include
>
>For you:
>
>> location ~ \.php$ {
>> root           /var/www/htdocs/sites/expertinet; <- you should avoid this,
>read http://wiki.nginx.org/Pitfalls
>
>include my_fastcgi_params;
>> include      
>> fastcgi_params;
>> }
>
>in my_fastcgi_params:
>
>fastcgi_pass   unix:/tmp/php.sock;
>#            fastcgi_pass   127.0.0.1:9000;
>fastcgi_index  index.php;
>fastcgi_param  SCRIPT_FILENAME      $document_root$fastcgi_script_name;
>
>--
>Cheers,
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130806/6aea6456/attachment.html>


More information about the nginx mailing list