515439429 发表于 2018-11-16 11:52:07

nginx 安装 (1 )

  开始学习nginx,初步安装nginx,先熟悉一下;参考网上的资料和涨宴老师书籍。
  http://nginx.org/en/download.html
  下载需要的版本,0.7版本的是稳定版本,0.8的是开发版本,看个人所好,我用的是nginx-0.8.48;
  一、安装
  1、检查安装nginx的依赖性,nginx的模块需要第三方库的支持,检查是否安装下列库:
  zlib、zlib-devel、openssl、openssl-devel、prce、prce-devel
  # rpm -qa |grep zlib
  zlib-devel-1.2.3-3
  zlib-1.2.3-3
  [root@mgmserver tar_packet]# rpm -qa |grep openssl
  openssl-0.9.8e-12.el5
  openssl-devel-0.9.8e-12.el5
  # rpm -qa |grep pcre
  pcre-6.6-2.el5_1.7
  pcre-devel-6.6-2.el5_1.7
  # rpm -qa |grep gcc
  compat-libgcc-296-2.96-138
  compat-gcc-34-g77-3.4.6-4
  gcc-c++-4.1.2-46.el5
  libgcc-4.1.2-46.el5
  compat-gcc-34-3.4.6-4
  compat-gcc-34-c++-3.4.6-4
  gcc-java-4.1.2-46.el5
  gcc-4.1.2-46.el5
  gccp-gfortran-4.1.2-46.el5
  # rpm -qa |grep autoconf
  autoconf-2.59-12
  # rpm -qa |grep automake
  automake-1.9.6-2.1
  automake16-1.6.3-8
  automake15-1.5-16
  automake17-1.7.9-7
  automake14-1.4p6-13
  2、添加nginx使用的用户和组 ,
  # groupadd nginx                   #nginx使用的组;
  # useradd -g nginx nginx      #nginx使用用户;
  3、安装
  # cd /home/tar_packet/
  # tar -zxvf nginx-0.8.48.tar.gz -C /home/install_packet/
  # cd ../install_packet/
  # cd nginx-0.8.48/
  # ls
  autoCHANGESCHANGES.ruconfconfigurecontribhtmlLICENSEREADMEsrc
  # ./configure --prefix=/usr/local/nginx \
  > --user=nginx \
  > --group=nginx \
  > --with-http_stub_status_module \   #启用“server status"页
  > --with-http_ssl_module                     #开启http ssl模块,使nginx可以支持https请求,这个模块需要已经
  安装openssl
  checking for OS
  + Linux 2.6.18-164.el5 i686
  checking for C compiler ... found
  checking for gcc builtin atomic operations ... not found
  checking for C99 variadic macros ... found
  checking for gcc variadic macros ... found
  checking for unistd.h ... found
  checking for inttypes.h ... found
  checking for limits.h ... found
  checking for sys/filio.h ... not found
  checking for sys/param.h ... found
  checking for sys/mount.h ... found
  checking for sys/statvfs.h ... found
  checking for crypt.h ... found
  checking for Linux specific features
  checking for epoll ... found
  checking for sendfile() ... found
  checking for sendfile64() ... found
  checking for sys/prctl.h ... found
  checking for prctl(PR_SET_DUMPABLE) ... found
  checking for sched_setaffinity() ... found
  checking for crypt_r() ... found
  checking for sys/vfs.h ... found
  checking for poll() ... found
  checking for /dev/poll ... not found
  checking for kqueue ... not found
  checking for crypt() ... not found
  checking for crypt() in libcrypt ... found
  checking for F_READAHEAD ... not found
  checking for posix_fadvise() ... found
  checking for O_DIRECT ... found
  checking for F_NOCACHE ... not found
  checking for directio() ... not found
  checking for statfs() ... found
  checking for statvfs() ... found
  checking for dlopen() ... not found
  checking for dlopen() in libdl ... found
  checking for sched_yield() ... found
  checking for SO_SETFIB ... not found
  checking for PCRE library ... found
  checking for OpenSSL library ... found
  checking for zlib library ... found
  creating objs/Makefile

  checking for int>
  checking for long>
  checking for long long>
  checking for void *>  checking for uint64_t ... found
  checking for sig_atomic_t ... found

  checking for sig_atomic_t>  checking for socklen_t ... found
  checking for in_addr_t ... found
  checking for in_port_t ... found
  checking for rlim_t ... found
  checking for uintptr_t ... uintptr_t found
  checking for system endianess ... little endianess

  checking for>
  checking for off_t>
  checking for time_t>  checking for setproctitle() ... not found
  checking for pread() ... found
  checking for pwrite() ... found
  checking for strerror_r() ... found but is not working
  checking for gnu style strerror_r() ... found
  checking for sys_errlist[] ... found
  checking for localtime_r() ... found
  checking for posix_memalign() ... found
  checking for memalign() ... found
  checking for mmap(MAP_ANON|MAP_SHARED) ... found
  checking for mmap("/dev/zero", MAP_SHARED) ... found
  checking for System V shared memory ... found
  checking for struct msghdr.msg_control ... found
  checking for ioctl(FIONBIO) ... found
  checking for struct tm.tm_gmtoff ... found
  checking for struct dirent.d_namlen ... not found
  checking for struct dirent.d_type ... found
  Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1 library is not used
  + using system zlib library
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
  #make
  #make install
  二、启动nginx
  # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  参数"-c"指定了配置文件的路径,如果不加'-c"参数, nginx,会默认加载其安装目录中conf子目录中的nginx.conf文件。
http://image18.360doc.com/DownloadImg/2010/12/0616/7411314_2.png
http://image18.360doc.com/DownloadImg/2010/12/0616/7411314_3.png
  # ps -ef |grep nginx
http://image18.360doc.com/DownloadImg/2010/12/0616/7411314_4.png
  可以看到一个主nginx的进程信息,一个子进程;如果在安装过程指定了“-pid-path=那么该文件就指定了nginx的主进程号,如果没有指定pid文件的存放路径,nginx.pid默认存放在nginx安装目录的logs子目录下,
  # ls
  access.logerror.lognginx.pid
  # cat nginx.pid
  6019
  三、nginx的信号控制
  ◆ TERM,INT 快速关闭
  ◆ QUIT 从容关闭
  ◆ HUP 平滑重启,重新加载配置文件
  ◆ USR1 重新打开日志文件,在切割日志时用途较大;
  ◆USR2 平滑升级可执行程序
  ◆ WINCH 从容关闭工作进程
  我们可以直接通过以下命令来完成平滑重启,省下寻找nginx主进程号的步骤;
  kill   -"信号类型”    ‘/usr/local/nginx/logs/nginx.pid'或者nginx的主进程号
  (1)、从容停止nginx
  # kill -QUIT 6019       #nginx主进程号
  # kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`
  (2)、快速停止nginx
  # kill -TERM /INTnginx主进程号
  # kill -TERM /INT `cat /usr/local/nginx/logs/nginx.pid
  (3)、强制停止所有的nginx进程
  #pkill   -9 nginx
  (4)、平滑重启nginx
  修改了nginx的配置文件要重启nginx;重启之前要检查配置文件是否正确:
  # /usr/local/nginx/sbin/nginx -t -c/usr/local/nginx/conf/nginx.conf
  the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  configuration file /usr/local/nginx/conf/nginx.conf test is successful
  # kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
  注意符号;
  nginx的平滑重启
  kill   -HUP Nginx主进程号
  或者
kill   -HUP      ·nginx.pid文件按存放路径
页: [1]
查看完整版本: nginx 安装 (1 )