centos7如何安装nginx

1.下载nginx

yum install wget -y && wget http://nginx.org/download/nginx-1.16.1.tar.gz

2.解压

tar -zxf nginx-1.16.1.tar.gz

3.切换到nginx解压目录下

cd nginx-1.16.1

4.创建nginx所属用户组

groupadd www

5.创建nginx所属用户

useradd -g www www -M -s /sbin/nologin

6.安装nginx依赖的软件,如果不安装编译的时候会报错。为了避免编译的时候报错,我们可以先安装一下这几个软件再进行编译
如果编译的时候报错:C compiler cc is not found,就安装一下gcc-c++

yum install gcc gcc-c++ -y

如果编译的时候报错:the HTTP rewrite module requires the PCRE library,就安装一下pcre-devel

yum install pcre-devel -y

如果编译的时候报错:SSL modules require the OpenSSL library,就安装一下openssl-devel

yum install openssl-devel -y

7.编译参数

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_sub_module --with-pcre

8.安装

make && make install

9.启动nginx

/usr/local/nginx/sbin/nginx

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: