yum -y groupinstall "Development Tools"
2.下载最新版本Nginx-1.6.0 网址http://nginx.org/en/download.html
3. 解压文件
tar zxvf nginx-1.6.0tar.gz
4. 拷贝到目录 /usr/local/下,并进入目录
cp nginx-1.6.0 /usr/local/nginx-1.6.0
cd nginx-1.6.0
5. 配置nginx
./configure --prefix=/usr/local/nginx
可能出现下列错误:
提示没有./configure权限
输入:chmod +x configure
错误提示 ./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-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
6.安装
make
make install
centos下 文件移动和重命名命令:mv file1 file2
7.启动
确保系统的 80 端口没被其他程序占用,
/usr/local/nginx/sbin/nginx
检查是否启动成功:
netstat -ano|grep 80 有结果输入说明启动成功
打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。
8.重启
/usr/local/nginx/sbin/nginx –s reload