fox111 发表于 2018-11-12 12:06:54

Nginx笔记2-love

  Nginx是开源软件,我们可以在这里下载最新的包,http://nginx.org/en/download.html,编译Nginx时,要注意磁盘空间,GCC编译器及相关工具,搭建yum,安装以下包,yum -y install gcc gcc-c++ autoconf automake,Nginx的一些模块需要第三方库的支持,yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel,这些包安装后就开始编译安装Nginx,tar zxvf nginx-0.8.46.tar.gz我们编译时,Nginx的configure脚本支持以下选项:
  --prefix= 安装路径
  --sbin-path= Nginx可执行文件安装路径(默认路径/sbin/nginx)
  --conf-path= 这里是指定nginx.conf的路径,默认是安装径/conf/nginx.conf
  --pid-path= 在nginx.conf中没有指定pid指令的情况下,默认的nginx.pid的路径。默认安装路径/logs/nginx.pid。
  --lock-path=在nginx.lock文件的路径
  --error-log-path=在nginx.conf中没有指定access_log指令的情况下,默认访问日志的路径。
  --user=在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。默认是nobody。
  --group=
  --builddir=DIR 指定编译的目录
  --with-rtsig_module 启用rtsig模块。
  --with-select_module(或--without-select_module)允许或不允许开启SELECT模式.默认安装模式.
  --with-poll_module或--without-poll_module允许或不允许开启POLL模式.--with-http_ssl_module开启HTTP SSL模块.
  上面只是常用的参数还有很多,用到自己在官网上去找,
  我编译如下: ./configure
  --prefix=/usr/local/nginx
  --sbin-path=/usr/sbin/nginx
  --conf-path=/etc/nginx/nginx.conf
  --error-log-path=/var/log/nainx/error.log
  --pid-path=/var/run/nginx/nginx.pid
  --lock-path=/var/lock/nginx.lock
  --user=nginx --group=nginx
  --with-http_ssl_module -
  -with-http_flv_module
  --with-http_gzip_static_module
  --http-log-path=/var/log/nginx/access.log
  --http-client-body-temp-path=/var/tmp/nginx/client
  --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi
  make
  make install
  Nginx启动:/usr/sbin/nginx -c /etc/nginx/nginx.conf
  Nginx停止:ps -ef | grep nginx
  root      8204   10 18:21 ?      00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
  nginx   820582040 18:21 ?      00:00:00 nginx: worker process
  root      823642360 18:23 pts/2    00:00:00 grep nginx
  Nginx进程的备注信息为“master process”,表示它为主进程,另外的一个进程信息为“worker process”,表示它们为子进程。 8204为主进程号。
  Nginx重启: /usr/sbin/nginx -t -c /etc/nginx/nginx.conf,如果成功可以看到两行信息:the configuration file /etc/nginx/nginx.conf syntax is ok
  configuration file /etc/nginx/nginx.conf test is successful
  Nginx接收的信号量:
  主进程
  TERM,INT 快速退出 Quick shutdown
  QUIT            正常退出 Graceful shutdown

  更新配置 Configuration>  HUP      Start the new worker processes with a new configuration
  Gracefully shutdown the old worker processes
  USR1   重新打开日志文件 Reopen the log files
  USR2   在线更新二进制运行文件 Upgrade Executable on the fly
  WINCH正常退出工作进程 Gracefully shutdown teh worker processes
  常用信号:
  kill -15 nginx_pid   (退出)
  kill -HUP nginx_pid (刷新配置)

页: [1]
查看完整版本: Nginx笔记2-love