官方文档 http://nginx.org/en/docs/configure.html
./configure
make
nginx依赖以下模块: //摘自网络
gzip模块需要 zlib 库
rewrite模块需要 pcre 库
ssl 功能需要openssl库
放弃用yum,直接wget http://nginx.org/download/nginx-1.8.1.tar.gz(我下的时候最新的稳定版1.8.1)
PuTTY登陆的时候光标前是[root@VM_ _centos ~]# ~是root目录
然后解压 tar -zxvf nginx-1.8.1.tar.gz
进入解压文件夹 cd nginx-1.8.1
./configure
make
make install
/usr/local/nginx/sbin/nginx 开启nginx
(默认安装目录/usr/local/nginx ,自己改了这里应该也要改,腾讯云的方法是/目录下 sevice nginx restart,没试过 http://www.qcloud.com/wiki/CentOS环境配置) Linux下的nginx启动、重新启动
最后用 wget http://127.0.0.1 测试
安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库
报错 ./configure: error: C compiler cc is not found
解决 yum install gcc gcc-c++ ncurses-devel perl
继续./configure
报错 ./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
报错 ./configure: error: the HTTP gzip module requires the zlib library.
解决 yum install -y zlib-devel
报错 ./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决 yum -y install openssl openssl-devel