Linux安装nginx

Linux安装nginx

1.所需依赖安装

需要进行依赖的安装 1.pcre2.openssl3.zlib

1.1 安装pcre依赖
  1. 使用linux下载安装包的方法
wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz

在这里插入图片描述

  1. 解压压缩文件
tar -xvf pcre-8.37.tar.gz

在这里插入图片描述

  1. 进入解压完的目录
yum -y install gcc   //需先进行gcc安装
yum install gcc-c++   //需先进行c++编译环境安装
./configure          //进入解压目录后执行
make && make install          //编译并且安装
pcre-config --version         //安装成功查看版本号

在这里插入图片描述在这里插入图片描述

1.2 安装其他依赖
 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

在这里插入图片描述

2.nginx安装

  1. nginx官网下载 linux的安装包
  2. 将安装包传输到Linux系统对应文件夹
  3. 解压安装包
 tar -xvf nginx-1.12.2.tar.gz
// 进入解压目录
./configure
  1. 编译并安装
make && make install
  1. 查看结果
    usr中会多出一个文件夹 local/nginx nginx中有一个sbin中有一个启动的脚本
[root@hadoop1 nginx-1.12.2]# cd /usr
[root@hadoop1 usr]# cd local
[root@hadoop1 local]# ls
bin  etc  games  include  lib  lib64  libexec  nginx  sbin  share  src
[root@hadoop1 local]# cd nginx
[root@hadoop1 nginx]# ls
conf  html  logs  sbin
[root@hadoop1 nginx]# cd sbin
[root@hadoop1 sbin]# ls
nginx
[root@hadoop1 sbin]#
  1. 启动nginx
[root@hadoop1 sbin]# ls
nginx
[root@hadoop1 sbin]# ./nginx  //启动nginx
[root@hadoop1 sbin]# ps -ef | grep nginx  //查看nginx进程
root      72816      1  0 16:30 ?        00:00:00 nginx: master process ./nginx
nobody    72817  72816  0 16:30 ?        00:00:00 nginx: worker process
root      72819  12658  0 16:30 pts/0    00:00:00 grep --color=auto nginx
  1. 打开linux防火墙的80端口
[root@hadoop1 conf]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
[root@hadoop1 conf]# sudo firewall-cmd --add-port=80/tcp --permanent
success
[root@hadoop1 conf]# firewall-cmd --reload
success
[root@hadoop1 conf]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports: 80/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

3.本机访问linux所安装的nginx

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值