1.下载http://nginx.org/en/download.html
直接在网页上下载到主机。你也可以wget下载,地址:http://nginx.org/download/nginx-1.8.0.tar.gz 这个具体的版本可以自己看看。
2.解压:tar -xf nginx-1.8.0.tar.gz
3.tar -xf nginx-1.8.0.tar.gz
./configure
make
sudo make install
4.创建文件夹
create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:
mkdir 创建文件夹 vi nginx.repo创建并直接打开
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=0enabled=1
使用./configure遇到的坑:
报错:
checking for OS
+ Linux 2.6.32-573.el6.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
出现这个错误。
那么就是gcc 包没有安装。安装gcc 吧,骚年。
yum -y install gcc
然而运行这句 可能会报错:
报了这个错的解决办法:
a. 打开/etc/yum.repos.d/xxxxx.repo,对于本例来说就是/etc/yum.repost.d/flexbox.repo
b. 将项[flexbox]中的enabled=1改为enabled=0
运行报错:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib
library
statically from the source with nginx by using –with-zlib=<path> option.
则需要安装“zlib-devel”即可。SSH执行以下命令:yum install -y zlib-devel
然后再运行 可能回出现如下错误:
安装nginx,执行make时,提示
make: *** 没有规则可以创建“default”需要的目标“build”。 停止。
认真看./configure结果,提示pcre not found
需要安装pcre
yum install pcre*
安装成功,继续执行make && make install,成功
6.我们进入sbin中启动nginx
出现了上面的报错。解决办法:
运行./nginx
注意:每次修改了nginx.conf之后一定要运行
./nginx -s reload