nginx入门
nginx特点
占用cpu/内存资源少,相对apache并发处理能力强
nginx安装
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
安装pcre? nginx要在rewrite时要解析正则表达式,PCRE是正则解析库
//下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz
抹去nginx的版本,该步非必需
[ nginx-1.13.7]# cat src/core/nginx.h /* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGINX_H_INCLUDED_ #define _NGINX_H_INCLUDED_ #define nginx_version 1013007 #define NGINX_VERSION "1.13.7" #define NGINX_VER "nginx/" NGINX_VERSION #ifdef NGX_BUILD #define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")" #else #define NGINX_VER_BUILD NGINX_VER #endif #define NGINX_VAR "NGINX" #define NGX_OLDPID_EXT ".oldbin" #endif /* _NGINX_H_INCLUDED_ */ [ nginx-1.13.7]# sed -i -e ‘s/1.13.7//g‘ -e ‘s/nginx\//WS/g‘ -e ‘s/"NGINX"/"WS"/g‘ src/core/nginx.h [ nginx-1.13.7]# [ nginx-1.13.7]# [ nginx-1.13.7]# cat src/core/nginx.h /* * Copyright (C) Igor Sysoev * Copyright (C) Nginx, Inc. */ #ifndef _NGINX_H_INCLUDED_ #define _NGINX_H_INCLUDED_ #define nginx_version 1013007 #define NGINX_VERSION "" #define NGINX_VER "WS" NGINX_VERSION #ifdef NGX_BUILD #define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")" #else #define NGINX_VER_BUILD NGINX_VER #endif #define NGINX_VAR "WS" #define NGX_OLDPID_EXT ".oldbin" #endif /* _NGINX_H_INCLUDED_ */
cd nginx-1.13.7
./configure --prefix=/usr/local/nginx
make
make install
添加环境变量
export PATH=/usr/local/nginx/sbin:$PATH