Register now and start sharing your code snippets.

Awstats LogFormat configuration for nginx LogFormat

Plain Text posted about 1 month ago by christian

This is my nginx LogFormat configuration:

   1  log_format main '$remote_addr - $remote_user [$time_local] $status '
   2                      '"$request" $body_bytes_sent "$http_referer" '
   3                      '"$http_user_agent" "http_x_forwarded_for"';

And this is my Awstats LogFormat configuration:

   1  LogFormat = "%host - %host_r %time1 %code %methodurl %bytesd %refererquot %uaquot %otherquot"

Tagged awstats, nginx, logformat, configuration

Sphinx configuration file template

Plain Text posted 4 months ago by christian

   1  source feed_items
   2  {
   3          type                    = mysql
   4  
   5          sql_host                = 127.0.0.1
   6          sql_user                = root
   7          sql_pass                =
   8          sql_db                  = xxx_production
   9          sql_port                = 3306  # optional, default is 3306
  10          sql_sock                = /var/run/mysqld/mysqld.sock
  11  
  12          sql_query_pre           = SET NAMES utf8
  13          #sql_query_pre          = SET SESSION query_cache_type=OFF
  14  
  15  	# Unique ID should be first column
  16          sql_query               = \
  17                  SELECT i.id, i.title, i.link, f.link, f.title FROM feed_items i LEFT JOIN feeds f ON f.id = i.feed_id
  18  }
  19  
  20  
  21  index feed_items
  22  {
  23          source                  = feed_items
  24          path                    = /var/sphinx/xxx
  25          morphology              = libstemmer_sv
  26          charset_type            = utf-8
  27  }
  28  
  29  
  30  indexer
  31  {
  32          mem_limit               = 32M
  33  }
  34  
  35  searchd
  36  {
  37          address                 = 127.0.0.1
  38          port                    = 3312
  39          log                     = /var/log/sphinx/searchd.log
  40          query_log               = /var/log/sphinx/query.log
  41          pid_file                = /var/log/searchd.pid
  42          max_matches             = 1000
  43  }
  44  

Tagged sphinx, template, configuration

Change nginx configuration on the fly

Shell Script (Bash) posted 10 months ago by christian

First make your changes to nginx.conf.

Then run the following command to test the new configuration:

   1  # nginx -t -c /etc/nginx/nginx.conf 
   2  2007/10/18 20:55:07 [info] 3125#0: the configuration file /etc/nginx/nginx.conf syntax is ok
   3  2007/10/18 20:55:07 [info] 3125#0: the configuration file /etc/nginx/nginx.conf was tested successfully

Next, look for the process id of the master nginx process:

   1  # ps -ef|grep nginx
   2  root      1911     1  0 18:00 ?        00:00:00 nginx: master process /usr/sbin/nginx
   3  www-data  1912  1911  0 18:00 ?        00:00:00 nginx: worker process

Lastly, tell nginx to reload the configuration and restart the worker processes:

   1  # kill -HUP 1911

Tagged nginx, reload, configuration