linux centor os7安装nginx

1.创建文件夹用来存放nginx

我的放在 /usr/apps/nginx

在这里插入图片描述

2.下载

进入到自己创建的文件夹nginx下执行

wget  http://nginx.org/download/nginx-1.13.0.tar.gz

如果提示未找到wget命令
先执行

yum -y install wget

在这里插入图片描述

3.解压

在nginx文件夹下解压
在这里插入图片描述

4.编译

在这里插入图片描述
进入nginx/nginx-1.13.0文件夹下

[root@localhost nginx]# ls
nginx-1.13.0  nginx-1.13.0.tar.gz
[root@localhost nginx]# cd nginx-1.13.0
[root@localhost nginx-1.13.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src

然后开始编译
在这里插入图片描述

./configure

报错1:
在这里插入图片描述错误原因:
缺少编译环境,安装编译源码所需要的工具和库

解决错误./configure: error: C compiler cc is not found错误
当前文件夹下执行命令

yum install gcc gcc-c++ ncurses-devel perl

在这里插入图片描述===========================================================
解决报错1后执行./configure可能会遇到报错2

报错2
./configure: error: the HTTP rewrite module requires the PCRElibrary.错误:
错误原因
缺少HTTP rewrite module模块,禁用或者安装所需要的模块。我们选择安装模块:
执行命令

yum install pcre pcre-devel

在这里插入图片描述
解决报错2后执行./configure可能会遇到报错3

报错3
./configure: error: the HTTP gzip module requires the zliblibrary.错误

错误原因
缺少HTTP zlib类库,我们选择安装模块

执行命令

yum  install zlib gzip zlib-devel

在这里插入图片描述

5.解决错误后重新编译

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

6安装nginx

make & make install

在这里插入图片描述安装成功
在这里插入图片描述

7.启动nginx

首先进入我们安装的nginx文件夹下

[root@localhost nginx-1.13.0]# cd /usr/local/nginx


[root@localhost nginx]# ls
client_body_temp  conf  fastcgi_temp  html  logs  proxy_temp  sbin  scgi_temp  uwsgi_temp


[root@localhost nginx]# cd sbin


[root@localhost sbin]# ls
nginx

在这里插入图片描述
启动

[root@localhost sbin]# ls
nginx


[root@localhost sbin]# ./nginx

查看nginx进程是否在运行

ps -ef|grep nginx

在这里插入图片描述
以上代表运行成功

浏览器访问

ip addr

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_41150890/article/details/108854151