nginx安装

安装相关依赖包

yum install pcre pcre-devel -y
yum install zlib zlib-devel -y
yum install gcc -y
yum install gd gd-devel -y
yum install openssl openssl-devel -y


 

下载nginx源码文件

http://nginx.org/en/download.html

nginx-1.12.0.tar.gz

 

 

创建用户组

groupadd www
useradd -g www www

 

解压源码文件包

tar -xvf nginx-1.12.0.tar.gz


 

进入安装目录

cd nginx-1.12.0

 

创建目录

mkdir -p /var/tmp/nginx/client

 

配置

./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--user=www \
--group=www \
--with-http_ssl_module \ #openssl模块,提供https支持
--with-http_flv_module \ #伪流媒体模块
--with-http_stub_status_module \ #nginx状态监控模块
--with-http_gzip_static_module \ #文件压缩模块,防止文件被重复压缩
--http-client-body-temp-path=/var/tmp/nginx/client \  #制定post上传的$_FILES上传的文件目录
--http-proxy-temp-path=/var/tmp/nginx/proxy \  #反向代理缓存目录
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi \ #接口协议文件目录
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ #线路协议文件目录
--http-scgi-temp-path=/var/tmp/nginx/scgi \  #类似fastcgi
--with-pcre \
--with-file-aio \  #同时提交多个io请求给内核
--with-http_image_filter_module  #裁剪过大的图片

 

编译安装

make&&make install

启动nginx

/usr/local/nginx/sbin/nginx

重启

/usr/local/nginx/sbin/nginx -s reload

 停止

/usr/local/nginx/sbin/nginx -s stop

 

查看nginx工作进程

ps -ef|grep nginx
root     10884     1  0 15:59 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www      10885 10884  0 15:59 ?        00:00:00 nginx: worker process

nginx默认配置启动成功后,会有两个进程,一个主进程(守护进程),一个工作进程。主进程负责管理工作进程,工作进程负责处理用户的http请求

 

 

配置nginx开机启动

echo "/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf" >>/etc/rc.d/rc.local

 

posted on 2017-05-12 15:56  宇宙小飞机  阅读(269)  评论(0编辑  收藏  举报

导航