zabbix

[root@client shenjianyu]# mkdir -pv /shenjianyu
[root@client shenjianyu]# cd /shenjianyu/
  1 安装依赖包
  [root@client shenjianyu]# yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel 2 查看系统版本
  [root@client shenjianyu]# cat /etc/issue 3 官网下载nginx-1.9.15   [root@client shenjianyu]# wget http://nginx.org/download/nginx-1.9.15.tar.gz
 4 添加nginx用户   [root@client shenjianyu]# useradd nginx -s /sbin/nologin -M 5 解压   [root@client shenjianyu]# tar -zxvf nginx-1.9.15.tar.gz 6 进入目录   [root@client shenjianyu]# cd nginx-1.9.15 7 编译安装
  nginx编译参数说明如下:
--prefix=<path> -- 安装路径,如果没有指定,默认为/usr/local/nginx。
--sbin-path=<path> -- nginx可执行命令的文件,如果没有指定,默认为<prefix>/sbin/nginx。
--conf-path=<path> -- 在没有使用-c参数指定的情况下nginx.conf的默认位置,如果没有指定,默认为<prefix>/conf/nginx.conf。
--pid-path=<path> -- nginx.pid的路径,如果没有在nginx.conf中通过“pid”指令指定,默认为<prefix>/logs/nginx.pid。
--lock-path=<path> -- nginx.lock文件路径,如果没有指定,默认为<prefix>/logs/nginx.lock。
--error-log-path=<path> -- 当没有在nginx.conf中使用“error_log”指令指定时的错误日志位置,如果没有指定,默认为<prefix>/logs/error.log。
--http-log-path=<path> -- 当没有在nginx.conf中使用“access_log”指令指定时的访问日志位置,如果没有指定,默认为<prefix>/logs/access.log。
--user=<user> -- 当没有在nginx.conf中使用“user”指令指定时nginx运行的用户,如果没有指定,默认为“nobody”。
--group=<group> -- 当没有在nginx.conf中使用“user”指令指定时nginx运行的组,如果没有指定,默认为“nobody”。
--builddir=DIR -- 设置构建目录。
--with-rtsig_module -- 启用rtsig模块。
--with-select_module --without-select_module -- 如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,select模块始终为启用状态。
--with-poll_module --without-poll_module -- 如果在configure的时候没有发现kqueue, epoll, rtsig或/dev/poll其中之一,poll模块始终为启用状态。
--with-http_ssl_module -- 启用ngx_http_ssl_module,启用SSL支持并且能够处理HTTPS请求。需要OpenSSL,在Debian系统中,对应的包为libssl-dev。
--with-http_realip_module -- 启用ngx_http_realip_module
--with-http_addition_module -- 启用ngx_http_addition_module
--with-http_sub_module -- 启用ngx_http_sub_module
--with-http_dav_module -- 启用ngx_http_dav_module
--with-http_flv_module -- 启用ngx_http_flv_module
--with-http_stub_status_module -- 启用”server status”(服务状态)页
--without-http_charset_module -- 禁用ngx_http_charset_module
--without-http_gzip_module -- 禁用ngx_http_gzip_module,如果启用,需要zlib包。
--without-http_ssi_module -- 禁用ngx_http_ssi_module
--without-http_userid_module -- 禁用ngx_http_userid_module
--without-http_access_module -- 禁用ngx_http_access_module
--without-http_auth_basic_module -- 禁用ngx_http_auth_basic_module
--without-http_autoindex_module -- 禁用ngx_http_autoindex_module
--without-http_geo_module -- 禁用ngx_http_geo_module
--without-http_map_module -- 禁用ngx_http_map_module
--without-http_referer_module -- 禁用ngx_http_referer_module
--without-http_rewrite_module -- 禁用ngx_http_rewrite_module。如果启用,需要PCRE包。
--without-http_proxy_module -- 禁用ngx_http_proxy_module
--without-http_fastcgi_module -- 禁用ngx_http_fastcgi_module
--without-http_memcached_module -- 禁用ngx_http_memcached_module
--without-http_limit_zone_module -- 禁用ngx_http_limit_zone_module
--without-http_empty_gif_module -- 禁用ngx_http_empty_gif_module
--without-http_browser_module -- 禁用ngx_http_browser_module
--without-http_upstream_ip_hash_module -- 禁用ngx_http_upstream_ip_hash_module
--with-http_perl_module -- 启用ngx_http_perl_module
--with-perl_modules_path=PATH -- 为perl模块设置路径
--with-perl=PATH -- 为perl库设置路径
--http-client-body-temp-path=PATH -- 为http连接的请求实体临时文件设置路径,如果没有指定,默认为<prefix>/client_body_temp
--http-proxy-temp-path=PATH -- 为http代理临时文件设置路径,如果没有指定,默认为<prefix>/proxy_temp
--http-fastcgi-temp-path=PATH - 为http fastcgi临时文件设置路径,如果没有指定,默认为<prefix>/fastcgi_temp
--without-http -- 禁用HTTP服务
--with-mail -- 启用IMAP4/POP3/SMTP代理模块
--with-mail_ssl_module -- 启用ngx_mail_ssl_module
--with-cc=PATH -- 设置C编译器路径
--with-cpp=PATH -- 设置C预处理器路径
--with-cc-opt=OPTIONS -- 变量CFLAGS中附加的参数,用于FreeBSD中的PCRE库,同样需要指定--with-cc-opt=”-I /usr/local/include”,如果我们使用select()函数则需要同时增加文件描述符数量,可以通过--with-cc-opt=”-D FD_SETSIZE=2048”指定。
--with-ld-opt=OPTIONS -- 通过连接器的附加参数,用于FreeBSD中的PCRE库,同样需要指定--with-ld-opt=”-L /usr/local/lib”。
--with-cpu-opt=CPU -- 指定编译的CPU,可用的值为: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
--without-pcre -- 禁用PCRE库文件,同时将禁用HTTP rewrite 模块,如果要在”location”指令中使用正则表达式,同样需要PCRE库。
--with-pcre=DIR -- 设置PCRE库源文件路径。
--with-pcre-opt=OPTIONS -- 在编译时为PCRE设置附加参数。
--with-md5=DIR -- 设置md5库源文件路径。
--with-md5-opt=OPTIONS -- 在编译时为md5设置附加参数。
--with-md5-asm -- 使用md5汇编源。
--with-sha1=DIR -- 设置sha1库源文件路径。
--with-sha1-opt=OPTIONS -- 在编译时为sha1设置附加参数。
--with-sha1-asm -- 使用sha1汇编源。
--with-zlib=DIR -- 设置zlib库源文件路径。
--with-zlib-opt=OPTIONS -- 在编译时为zlib设置附加参数。
--with-zlib-asm=CPU -- 为指定的CPU使用zlib汇编源进行优化,可用值为: pentium, pentiumpro。
--with-openssl=DIR -- 设置openssl库源文件路径。
--with-openssl-opt=OPTIONS -- 在编译时为openssl设置附加参数。
--with-debug -- 启用debug记录。
--add-module=PATH -- 增加一个在PATH中的第三方模块。
  
  [root@client shenjianyu]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre
  [root@client shenjianyu]# make
  [root@client shenjianyu]# make install
  [root@client shenjianyu]# cd /usr/local/nginx/conf/
  [root@client shenjianyu]# cp nginx.conf nginx.conf.`date +%F`
  [root@client shenjianyu]# vim nginx.conf  
  [root@client conf]# grep -Ev '#' nginx.conf
  

  [root@client logs]# grep -Ev '#' /usr/local/nginx/conf/nginx.conf

worker_processes 1;

 


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

 

sendfile on;

keepalive_timeout 65;


server {
listen 80;
server_name localhost;

 

location / {
root html;
index index.html index.htm;
}


error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

location ~ .php$ {

root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}

}

  [root@client shenjianyu]# cd /etc/init.d/

  [root@client shenjianyu]# vim nginx

 
 #!/bin/bash
 PID="/usr/local/nginx/logs/nginx.pid"
 start(){
  /usr/local/nginx/sbin/nginx
  if [ $? -eq 0 ];then
    echo -en "Starting Nginx...			["
     echo -en "33[32;34mOK33[0m"
     echo "]"
  else
    echo "Starting Nginx Error"
  fi
 }
 stop(){
  /usr/local/nginx/sbin/nginx -s stop
  if [ $? -eq 0 ];then
     echo -en "Stop Nginx...			["
     echo -en "33[32;34mOK33[0m"
     echo "]"
  else
     echo "Stop Nginx Error"
  fi
 }
 status(){
  if [ -f $PID ];then
     ID=$(cat $PID)
     echo "Ngix($ID) is running..."
  else
     echo "Nginx is stop"
  fi
 }
 case $1 in
 start)
   start;;
 stop)
   stop;;
 restart)
   stop
   start
   ;;
 status)
   status;;
 *)
   echo "Usage:$0 {start|stop|restart|status}"
 esac
 
 [root@client init.d]# /etc/init.d/nginx restart
 Stop Nginx... [OK]
 Starting Nginx... [OK] 
 
 [root@client init.d]# cd /usr/local/nginx/logs/
 [root@client logs]# ls
 access.log error.log nginx.pid(重启后pid文件生成

  [root@client sbin]# chkconfig nginx on
service nginx does not support chkconfig

  很是奇怪,后经过查找资料,发现如果想添加脚本用service启动,必须要脚本里面包含这2行:

# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve

其他的都无所谓,只是个注意而已!!!

  [root@client sbin]# chkconfig nginx on  


测试:(成功) [root@client logs]# curl 172.30.1.208   <!DOCTYPE html>   <html>   <head>   <title>Welcome to nginx!</title>   <style>   body {    35em;   margin: 0 auto;   font-family: Tahoma, Verdana, Arial, sans-serif;   }   </style>   </head>   <body>   <h1>Welcome to nginx!</h1>   <p>If you see this page, the nginx web server is successfully installed and    working. Further configuration is required.</p>   <p>For online documentation and support please refer to    <a href="http://nginx.org/">nginx.org</a>.<br/>   Commercial support is available at   <a href="http://nginx.com/">nginx.com</a>.</p>   <p><em>Thank you for using nginx.</em></p>   </body>    </html>
原文地址:https://www.cnblogs.com/shenjianyu/p/6530547.html