- 安装和更新基础软件服务 - 必须是宿主机上进行,不然端口的问题不好处理
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel -y
- 创建nginx存放目录
mkdir -p /usr/local/nginx
- 下载、编译并安装nginx
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz
cd nginx-1.13.7
- 必须使用该方式配置,否则编译安装后ssl功能无法使用
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_module
- 编译
make
- 安装
make install
- 创建www 目录,避免报【nginx: [emerg] getpwnam(“www”) failed】错误
/usr/sbin/groupadd -f www
/usr/sbin/useradd -g www www
- 上传准备好的nginx配置文件到/usr/local/nginx/conf底下(可选)
- 启动nginx , 没报错就是成功
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- 查看结果
http://localhost:80/
11.添加Nginx环境变量(可选)
参见//www.greatytc.com/p/eed820860ae5