Welcome! Log In Create A New Profile

Advanced

Re: Avice for my vhost configuration

August 06, 2013 04:12AM
--- Original message ---
From: "Mik J" <mikydevel@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,

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Avice for my vhost configuration

miky August 05, 2013 05:46PM

Re: Avice for my vhost configuration

B.R. August 05, 2013 08:42PM

Re: Avice for my vhost configuration

artem August 06, 2013 04:12AM

Re: Avice for my vhost configuration

miky August 06, 2013 03:42PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready