环境搭建---nginx

nginx离线安装

下载地址:https://nginx.org/download/

一、安装编译工具及库文件

[root@VM-20-14-centos ~]# yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

在这里插入图片描述

二、安装 PCRE

[root@VM-20-14-centos ~]# tar -zxvf pcre-8.35.tar.gz
[root@VM-20-14-centos ~]# cd pcre-8.35
[root@VM-20-14-centos pcre-8.35]# ./configure
[root@VM-20-14-centos pcre-8.35]# make && make install

查看pcre版本

[root@VM-20-14-centos pcre-8.35]# pcre-config --version

在这里插入图片描述

三、安装 Nginx

[root@VM-20-14-centos ~]# tar -zxvf nginx-1.6.2.tar.gz
[root@VM-20-14-centos nginx-1.6.2]# ./configure
#需要指定安装目录等内容,可添加如下参数
[root@VM-20-14-centos src]# cd nginx-1.6.2
[root@VM-20-14-centos nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@VM-20-14-centos nginx-1.6.2]# make

–prefix=/usr/local/webserver/nginx指定nginx安装路径为/usr/local/webserver/nginx
–with-http_stub_status_module开启stub_status监控模块
–with-http_ssl_module开启nginx-http-ssl模块,为https提供支持,一般使用listen代替,不开启
–with-pcre=/usr/local/src/pcre-8.35指定pcre地址

查看nginx版本

[root@VM-20-14-centos nginx-1.6.2]# cd /usr/local/nginx/sbin/nginx
[root@VM-20-14-centos sbin]# ./nginx -v

在这里插入图片描述
启动nginx

[root@VM-20-14-centos sbin]# ./nginx

在这里插入图片描述
其他命令

# 重新载入配置文件
/usr/local/webserver/nginx/sbin/nginx -s reload
# 重新打开日志文件
/usr/local/webserver/nginx/sbin/nginx -s reopen
# 停止 Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop

docker安装nginx

[root@VM-20-14-centos ~]# docker pull nginx
[root@VM-20-14-centos ~]# docker run --name nginx-test -p 8081:80 -d nginx
#查看docker 镜像进程
[root@VM-20-14-centos ~]# docker ps

[root@VM-20-14-centos ~]# mkdir -p /data/nginx/www /data/nginx/log /data/nginx/conf
[root@VM-20-14-centos ~]# docker cp 容器id:/etc/nginx /data/nginx/conf
[root@VM-20-14-centos ~]# docker stop nginx-test
[root@VM-20-14-centos ~]# docker run --name nginx -p 8081:80 -v /data/nginx/conf/nginx:/etc/nginx -v /data/nginx/log:/var/log/nginx -v /data/nginx/www:/usr/share/nginx/html -d nginx

#查看docker 镜像进程
[root@VM-20-14-centos ~]# docker ps

在这里插入图片描述
在~/nginx/www 下创建 index.html
重新访问:localhost:8082

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值