2014年1月3日 13:52:07
喜欢这样的风格,干货
http://huoding.com/2013/10/23/290
-----------------下边是我自己的经验(windows)-----------------------
启动nginx
f:/nginxserver/nginx/nginx.exe -c f:/nginxserver/nginx/conf/nginx.conf
在windows下启动nginx要在命令行里进入nginx.exe的那个目录里,否则会提示不能创建日志文件(不能简单的改写环境变量)
nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (3: The system cannot find the path specified)
如果域名比较多的话,在http配置块里添加指令:server_names_hash_bucket_size 64;
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
如果server 配置块儿中的字符集配置指令如果和默认的冲突了,那就会被忽略掉(我设置为utf8,的冲突了)
1 nginx: [warn] conflicting server name "charset" on 0.0.0.0:80, ignored 2 nginx: [warn] conflicting server name "utf8" on 0.0.0.0:80, ignored
server 块中可以指定日志路径和日志格式,如果指定了日志格式(这里是main),就得保证这个日志格式在http块儿中已经被声明定义了
nginx: [emerg] unknown log format "main" in F:\vc9server\nginx\conf\apache.conf:17
如果全局中已经定义了日志配置指令,则虚拟机中的会被忽略
nginx: [warn] conflicting server name "access_log" on 0.0.0.0:80, ignored
http块儿中的日志格式定义(main为格式名字, 后边的字符串是具体格式)
1 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 2 '$status $body_bytes_sent "$http_referer" ' 3 '"$http_user_agent" "$http_x_forwarded_for"';
终止nginx
taskkill /F /IM nginx.exe > nul