Centos7:nginx的安装,配置及使用

安装依赖

yum install gcc-c++//gcc环境

yum install -y pcre pcre-devel//PCRE:nginx的http模块使用pcre来解析正则表达式

yum install -y zlib zlib-devel //zlib:nginx使用zlib对http包的内容进行gzip

yum install -y openssl openssl-devel//openssl:nginx支持https(即在ssl协议上传输http)

在/var下创建temp及nginx目录

mkdir /var/temp/nginx/client -p

解压缩,创建makeFile文件

使用configure命令创建一makeFile文件

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

安装nginx

make//编译

make install//安装

启动 nginx

./nginx//启动

./nginx -s stop 或者./nginx -s quit(推荐) 关闭nginx

./nginx -s reload //重启