首页 > 代码库 > centos7下安装nginx
centos7下安装nginx
1.从官网(http://nginx.org/)下载安装包
笔者下载版本为nginx-1.10.2.tar.gz
2.使用tar命令解压
tar xvf nginx-1.10.2.tar.gz
cd nginx-1.10.2/
./configure --prefix=/usr/local/nginx (prefix指定安装目录)
注意:在此步骤中因为缺少相关依赖库会出现以下问题:
./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.
直接安装openssl解决问题
yum -y install openssl openssl-devel
解决上述问题后重新执行
./configure --prefix=/usr/local/nginx
make
make install
3.安装完毕后去安装目录启动Nginx
sh /usr/local/nginx/sbin/nginx
centos7下安装nginx