nginx安装

nginx是一个高性能的反向代理服务器
正向代理代理的是客户端
反向代理代理的是服务端

安装步骤如下

1、下载安装文件 nginx-1.12.2.tar.gz 并移动到nginx文件夹下

2、依次执行如下命令 解压文件 并修改解压后的文件夹名称为 nginx112
tar -zvxf nginx-1.12.2.tar.gz
mv nginx-1.12.2 nginx112

[root@zk03 nginx]# ll
总用量 960
drwxr-xr-x. 9 1001 1001    186 1月  22 17:33 nginx112
-rw-r--r--. 1 root root 981687 2月  19 2019 nginx-1.12.2.tar.gz

3、安装 c++编译环境 及依赖环境

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

4、到nginx112目录下安装 nginx

 [root@zk03 nginx112]# ./configure 

提示 需要 PCRE library 如下:

./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=<path> option.

执行 yum install -y pcre-devel 安装

5、执行 ./configure 提示 需要 zlib library

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

执行 yum install -y zlib-devel 安装 zlib-devel

6.再次执行 ./configure 成功。

7.执行 make &&make install 编译并安装
通过输出的日志可以看到 默认将 nginx 安装到了 /usr/local/nginx 目录 可以再 执行 configure时prefix 参数 (如 ./configure --prefix /usr/apps/nginx) 来指定安装位置
日志信息:

sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
        -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
        -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
        -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
        < man/nginx.8 > objs/nginx.8

也可以通过 whereis nginx 找到安装位置 如下

[root@zk03 nginx]# whereis nginx
nginx: /usr/local/nginx

可以在该目录 下看到四个文件夹

[root@zk03 nginx112]# cd  /usr/local/nginx
[root@zk03 nginx]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 1月  23 10:11 conf
drwxr-xr-x. 2 root root   40 1月  23 10:11 html
drwxr-xr-x. 2 root root    6 1月  23 10:11 logs
drwxr-xr-x. 2 root root   19 1月  23 10:11 sbin

html:服务器资源文件根目录 比如一些静态图片 放在这里
sbin:工具命令 目录
conf:配置文件目录
logs :日志文件目录
8.nginx基本操作

sbin/nginx 启动nginx
启动后 浏览器中访问主机地址(我这里是zk03)即可访问到在这里插入图片描述

sbin/nginx -s stop(quit) 停止
sbin/nginx -s reload 重新加载配置
sbin/nginx -h 命令帮助
sbin/nginx -t 验证配置文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

catch that elf

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值