Linux下安装nginx

linux下安装nginx

————————————————————————
系统环境:
这里写图片描述
第一步:从http://nginx.org/en/download.html上下载相应的版本,这里下载的是当前的稳定版本nginx-1.12.2.tar.gz。
第二步:解压 tar -xzvf nginx-1.12.2.tar.gz
第三步:设置一下配置信息./configure –prefix=/usr/local/nginx(配置安装目录),或者不执行此步,直接默认配置
如果该步骤出现错误

/configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using –without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using –with-pcre= option.

可以使用以下命令

wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz
wget https://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2m.tar.gz

下载源代码文件,然后解压
tar -xzvf pcre-8.41.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
tar -xzvf openssl-1.0.2m.tar.gz
之后执行配置命令

./configure –prefix=/usr/local/nginx –with-pcre=pcre-8.41 –with-zlib=zlib-1.2.11 –with-http_ssl_module –with-openssl=openssl-1.0.2m

第四步:make编译(make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件),make install安装(make install把这些编译出来的可执行文件和库文件复制到合适的地方)。安装完成
这里写图片描述

启动nginx
使用命令/usr/local/nginx/sbin/nginx启动nginx
关闭nginx
使用ps -ef|grep nginx命令查看nginx的主进程号,这里是16776
这里写图片描述
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 nginx

conf配置文件:当我们使用nginx进行配置时,需要对conf/nginx.conf文件进行修改,这个文件如果是只读的,那么我们需要先修改它的权限,使用命令chmod -R a+w conf/nginx.conf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值