首先我们需要搭建一些扩展
sudo -s
LANG=C
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel pcre pcre-devel
一、首先安装pcre扩展
1.下载pcre
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
2.安装pcre
#tar -zxvf pcre-8.33.tar.gz
#cd pcre-8.33
#./configure
#make
#make install
二、下载nginx
1.下载包
wget http://nginx.org/download/nginx-1.9.5.tar.gz
2.解压,安装
#tar -zxvf nginx-1.9.5.tar.gz
#cd nginx-1.9.5
#./configure --user=nginx\
--group=nginx\
--prefix=/usr/local/nginx \
--with-http_stub_status_module \ #启用 nginx 的 NginxStatus 功能,用来监控 Nginx 的当前状态
--with-http_ssl_module \
--with-pcre=../pcre-8.33 #指向解压的源码目录
#make && make install
三、
配置用户操作nginx日志
groupadd nginx
useradd -g nginx
nginx
mkdir -p /var/log/nginx
chmod +w /var/log/nginx
chown -R nginx:nginx /var/log/nginx
四、
不停止nginx的服务,平滑变更nginx配置
(1)首先检查nginx的配置是否正确
/usr/local/nginx/sbin/nginx.conf -t
如果出现,配置成功
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successfull
(2)平滑重启
/usr/local/nginx/sbin/nginx -s reload
遇到的问题
1.系统中没有安装C语言
yum install gcc来解决问题
2.nginx启动报错
将nginx.conf中的user default;注释去掉
或者创建一个www的用户组和www的用户
#/usr/sbin/groupadd -f www
#/usr/sbin/useradd -g www www