一:安装nginx前
1:更新系统软件
yum update
2:安装wget
yum install wget
3:安装编译器
yum install gcc gcc-c++
二:安装nginx
1:安装nginx依赖包
nginx的Rewrite模块和HTTP核心模块会使用到PCRE正则表达式语法:
yum install pcre pcre-devel -y
nginx的各种模块中需要使用gzip压缩:
yum -y install zlib zlib-devel
安全套接字层密码库:
yum -y install openssl openssl-devel
2:下载nginx包并解压(到/usr/local/目录下)
cd /usr/local/
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
3:编译安装(到/usr/local/下)
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx
make && make install
4:创建并设置nginx运行账号:
groupadd nginx
useradd -M -g nginx -s /sbin/nologin nginx
cd /usr/local/nginx/conf
vim nginx.conf,设置user参数如下ÿ