FreeBSD & nginx

KaMaToZzz nginx-forum на nginx.us
Вт Ноя 23 16:31:36 MSK 2010


Не хочет заводиться nginx:


[code]
fun# /usr/local/etc/rc.d/nginx start
Performing sanity check on nginx configuration:
[emerg]: "if" directive is not allowed here in
/usr/local/etc/nginx/sites-enabled/www:13
configuration file /usr/local/etc/nginx/nginx.conf test failed
Starting nginx.
[emerg]: "if" directive is not allowed here in
/usr/local/etc/nginx/sites-enabled/www:13
/usr/local/etc/rc.d/nginx: WARNING: failed to start nginx
[/code]

[b]При nginx.conf[/b]
[code]
fun# cat nginx.conf

user www;
worker_processes 1;

pid /var/run/nginx.pid;
error_log /var/log/nginx-error.log warn;

events {
worker_connections 1024;
use kqueue;
}

http {
include mime.types;
default_type application/octet-stream;
include /usr/local/etc/nginx/sites-enabled/www;


# log options
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';

# nginx options
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;

# fastcgi
fastcgi_intercept_errors on;

# virtual server
server {
listen 80;
server_name fun.viks.net.ua;

access_log /var/log/nginx.fun.viks.net.ua.log main;

# server root directory
location / {
root /www/;
index index.php index.html index.htm;
   if (!-e $request_filename ) {
        rewrite ^(.*)$ /index.php?q=$1;
  }
}

# php
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;
include fastcgi_params;
}

# phpMyAdmin
location ~ ^/phpmyadmin/(.*\.php)$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/www/phpMyAdmin/$1;
fastcgi_param DOCUMENT_ROOT /usr/local/www/phpMyAdmin;
}

location /phpmyadmin {
alias /usr/local/www/phpMyAdmin/;
index index.php;

# authorization
auth_basic "Authorization Required";
auth_basic_user_file /usr/local/www/phpMyAdmin/.htpasswd;
}

 sendfile        on;
    #tcp_nopush     on;
client_max_body_size 100M;
}
}

[/code]

[b]И sites-enabled/www[/b]

[code]
fun# cat www
server {
  listen fun.viks.net.ua:80;
  server_name www.fun.viks.net.ua;
  rewrite ^(.*) http://fun.viks.net.ua$1 permanent;
}

  access_log /var/log/nginx/drupal-cgm.access.log;
  error_log /var/log/nginx/drupal-cgm.error.log;

  root /www;

  # restrict request methods to: GET|HEAD|POST
  if ( $request_method !~ ^(GET|HEAD|POST)$ ) {
    return 444;
    break;
  }

  # hide drupal system files
  location ~*
((cron\.php|settings\.php)|\.(htaccess|engine|inc|info|install|module|profile|pl|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(Entries.*|Repository|Root|Tag|Template))$
{
    deny all;
  }

#  # rewrite domain name without the leading www.
#  if ($host ~* ^www\.(.*)) {
#    set $host_without_www $1;
#    # bellow $1 contains '/foo', not 'www.mydomain.com/foo'
#    rewrite ^(.*)$ http://$host_without_www$1 permanent;
#  }

  location / {
    index index.php index.html;
    try_files $uri $uri/ @www;
  }

  location @www {
    # clean url rewrite for Drupal
    rewrite ^/(.*)$ /index.php?q=$1 last;
    #rewrite ^/(\w*)/(.*)$ /$1/index.php?q=$2 last;
  }

  location ~ \.php$ {
    include /usr/local/etc/nginx/fastcgi_params;
    fastcgi_pass unix:/tmp/php-fastcgi.socket;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

[/code]

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,152630,152650#msg-152650




Подробная информация о списке рассылки nginx-ru