编写nginx.conf,将nginx设置为单进程调试模式
为了方便使用调试器, 可以单进程非daemon方式启动, 使用参数:
编写模块ngx_module_echo
在ngx_module_echo
回到nginx的源码目录进行安装:
然后运行一下看看,先测一下配置文件的正确性:
运行之:
在另一个终端执行一个curl:
- worker_processes 1;
- error_log logs/error.log debug; # 记录调试日志
- master_process off; # 单进程模式
- daemon off;
- pid /tmp/nginx_debug.pid;
- events {
- worker_connections 1024;
- }
- http {
- include /etc/nginx/mime.types;
- sendfile on;
- keepalive_timeout 65;
- tcp_nodelay on;
- server {
- listen 80;
- server_name localhost;
- access_log /tmp/access.log;
- error_log /tmp/error.log debug;
- location /hello {
- echo "helloworld";
- }
- }
- }
为了方便使用调试器, 可以单进程非daemon方式启动, 使用参数:
- daemon off;
- master_process off;
编写模块ngx_module_echo
在ngx_module_echo
回到nginx的源码目录进行安装:
- ~/nginx-0.8.9/#./configure --add-module=/home/doyoueat/ngx_module_echo/ --with-debug
- make
- sudo make install
然后运行一下看看,先测一下配置文件的正确性:
- ~/nginx-0.8.9/#./objs/nginx -c /home/doyoueat/ngx_module_echo/nginx.conf -t
- the configuration file /home/doyoueat/ngx_module_echo/nginx.conf syntax is ok
- configuration file /home/doyoueat/ngx_module_echo/nginx.conf test is successful
运行之:
- ~/nginx-0.8.9/#./objs/nginx -c /home/renlu/ngx_module_echo/nginx.conf
在另一个终端执行一个curl:
- ~#curl http://127.0.0.1/hello
- helloworld