Linux-CentOS安装Nginx

52 阅读1分钟

1、下载Nginx安装包

nginx.org/en/download…

2.1、安装Nginx相关依赖

#安装nginx所需要的依赖包

yum -y install pcre-devel openssl-devel zlib-devel
yum -y install gcc gcc-c++

#解压

tar -zxvf nginx依赖的环境安装包.tar.gz

2.2、安装Nginx

进入nginx目录

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

如果遇到报错“./configure: error: C compiler cc is not found”

解决:

yum -y install gcc gcc-c++ autoconf automake make

编译和安装 Nginx

make
make install

2.3、启动Nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf