小言_互联网的博客

linux centor os7安装nginx

442人阅读  评论(0)

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


转载:https://blog.csdn.net/qq_41150890/article/details/108854151
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场