本文主要包含nginx总结,apache和nginx的区别,nginx,配置nginx,实战nginx等服务器相关知识,网友希望可以进行参考
1.通过nginx的安装脚本来讲解nginx的安装
- #!/bin/bash
- #author zhangyifei
- #2013 2.27
- #email zyfforlinux@163.com
- #源码包的下载
- cd /usr/local/src
- wget http://down1.chinaunix.net/distfiles/nginx-1.2.5.tar.gz
- wget http://down1.chinaunix.net/distfiles/pcre-8.30.tar.bz2
- #pcre库的安装以支持nginx的rewiter的正则表达式
- tar jxvf pcre-8.30.tar.bz2
- cd pcre-8.30
- ./configure
- make && make install
- cd ..
- pcredir="pcre-8.30"
- soft="nginx-1.2.5.tar.gz"
- softdir="nginx-1.2.5"
- if [ -f $soft ]; then
- tar zxvf $soft
- else
- echo "$soft not exis"
- exit
- fi
- #询问用户是否安装ssl模块和status模块
- read -p "do you install http_stub_status_module [Y/N]" args1
- echo "$args1"
- while [ "$args1" != "Y" ] && [ "$args1" != "y" ] && [ "$args1" != "N" ] && [ "$args1" != "n" ]
- do
- read -p "please input [Y/N]" args1
- done
- if [ "$args1" == "Y" ] || [ "$args1" == "y" ]; then
- args1="--with-http_stub_status_module"
- else
- args1=""
- fi
- echo "$args1"
- read -p "do you install --with-http_ssl_module [Y/N]" args2
- while [ "$args2" != "Y" ] && [ "$args2" != "y" ] && [ "$args2" != "N" ] && [ "$args2" != "n" ]
- do
- read -p "please input [Y/N]" args2
- done
- echo "$args2"
- if [ "$args2" == "Y" ] || [ "$args2" == "y" ]; then
- args2="--with-http_ssl_module"
- else
- args2=""
- fi
- echo "$args2"
- #创建启动nginx的用户 并且不可登录
- nginxuser="nginx"
- useradd -s /sbin/nolgin $nginxuser
- cd $softdir
- ./configure --prefix=/usr/local/nginx \
- --user=$nginxuser \
- --group=$nginxuser \
- --with-pcre=/usr/local/src/$pcredir \
- $args1 $args2
- make && make install
2.下面讲解nginx的默认配置文件
- #user nobody; 指定启动nginx的用户和用户组
- worker_processes 1; 指定开启nginx的进程数 一般和逻辑cpu的
- #error_log logs/error.log; 错误日志的存放位置 和格式
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid; 进程ID文件的存放位置

