Linux安装nginx
1.所需依赖安装
需要进行依赖的安装 1.pcre2.openssl3.zlib
1.1 安装pcre依赖
- 使用linux下载安装包的方法
wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
- 解压压缩文件
tar -xvf pcre-8.37.tar.gz
- 进入解压完的目录
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安装
- 到nginx官网下载 linux的安装包
- 将安装包传输到Linux系统对应文件夹
- 解压安装包
tar -xvf nginx-1.12.2.tar.gz
// 进入解压目录
./configure
- 编译并安装
make && make install
- 查看结果
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]#
- 启动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
- 打开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: