安裝nginx 需要檢查的依賴庫

nginx是本身就可以實現靜態資源的web服務
1、檢查安裝nginx的依賴性,nginx的模塊需要第三方庫的支持,檢查是否安裝下列庫:

zlib、zlib-devel、openssl、openssl-devel、prce、prce-devel

[root@mgmserver ~]# 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
[root@mgmserver tar_packet]# rpm -qa |grep pcre
pcre-6.6-2.el5_1.7
pcre-devel-6.6-2.el5_1.7
[root@mgmserver tar_packet]# 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
[root@mgmserver tar_packet]# rpm -qa |grep autoconf
autoconf-2.59-12
[root@mgmserver tar_packet]# 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使用的用戶和組 ,
[root@mgmserver ~]# groupadd nginx                   #nginx使用的組;
[root@mgmserver ~]# useradd -g nginx nginx      #nginx使用用戶;
3、安裝
[root@mgmserver ~]# cd /home/tar_packet/
[root@mgmserver tar_packet]# tar -zxvf nginx-0.8.48.tar.gz -C /home/install_packet/
[root@mgmserver tar_packet]# cd ../install_packet/
[root@mgmserver install_packet]# cd nginx-0.8.48/
[root@mgmserver nginx-0.8.48]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  README  src

[root@mgmserver nginx-0.8.48]# ./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 size ... 4 bytes
checking for long size ... 4 bytes
checking for long long size ... 8 bytes
checking for void * size ... 4 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
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 size_t size ... 4 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 4 bytes
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"


[root@mgmserver nginx-0.8.48]#make
[root@mgmserver nginx-0.8.48]#make install

二、啓動nginx
[root@mgmserver nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

參數"-c"指定了配置文件的路徑,如果不加'-c"參數, nginx,會默認加載其安裝目錄中conf子目錄中的nginx.conf文件。


 

 


[root@mgmserver nginx-0.8.48]# ps -ef |grep nginx

可以看到一個主nginx的進程信息,一個子進程;如果在安裝過程指定了“-pid-path=<path>那麼該文件就指定了nginx的主進程號,如果沒有指定pid文件的存放路徑,nginx.pid默認存放在nginx安裝目錄的logs子目錄下,

[root@mgmserver logs]# ls
access.log  error.log  nginx.pid
[root@mgmserver logs]# cat nginx.pid
6019

三、nginx的信號控制

 TERM,INT 快速關閉

 QUIT 從容關閉

 HUP 平滑重啓,重新加載配置文件

 USR1 重新打開日誌文件,在切割日誌時用途較大;

 USR2 平滑升級可執行程序

 WINCH 從容關閉工作進程

 

我們可以直接通過以下命令來完成平滑重啓,省下尋找nginx主進程號的步驟;

kill   -"信號類型”    ‘/usr/local/nginx/logs/nginx.pid'或者nginx的主進程號

(1)、從容停止nginx

[root@mgmserver ~]# kill -QUIT 6019       #nginx主進程號
[root@mgmserver logs]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`

(2)、快速停止nginx

[root@mgmserver logs]# kill -TERM /INT   nginx主進程號

 [root@mgmserver logs]# kill -TERM /INT   `cat /usr/local/nginx/logs/nginx.pid

(3)、強制停止所有的nginx進程

#pkill   -9 nginx

(4)、平滑重啓nginx

修改了nginx的配置文件要重啓nginx;重啓之前要檢查配置文件是否正確:

[root@mgmserver html]# /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

[root@mgmserver conf]# kill -HUP `cat /usr/local/nginx/logs/nginx.pid`

注意符號;
nginx的平滑重啓

kill     -HUP Nginx主進程號

或者

kill     -HUP        ·nginx.pid文件按存放路徑·

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章