nginx 安装

nginx 安装

安装必要软件

yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

下载安装包

wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

解压

tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1

配置

  1. 默认配置
./configure
  1. 自定义配置(非不要不使用)
./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/conf/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

编译安装

make & make install

启动、停止nginx

cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload

查看nginx进程

ps aux|grep nginx

重启nginx

  1. 先停止再启动(推荐)
./nginx -s quit
./nginx
  1. 重新加载配置文件

当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:

./nginx -s reload

设置开机自启动

即编辑 /etc/rc.local , 增加一行:

/usr/local/nginx/sbin/nginx

设置执行权限:

chmod 755 rc.local

posted on 2018-02-09 11:27  大胡子爸爸  阅读(81)  评论(0)    收藏  举报

导航