1.下载Nginx
#下载 Stable version
https: / / nginx. org/ en/ download. html
2.安装依赖环境
1. 安装gcc环境
yum install gcc-c++
2. 安装pcre库,用于解析正则表达式
yum install -y pcre pcre-devel
3. zlib压缩和解压缩
yum install -y zlib zlib-devel
4. SSL安全的加密的套接字协议层,用于HTTP安全传输,也就是HTTPS
yum install -y openssl openssl-devel
3.解压Nginx
tar - zxvf nginx- 1. 18. 0. tar. gz
4.编译之前,创建Nginx临时目录
mkdir / var / temp/ nginx - p
5.在Nginx目录,输入如下命令进行配置,目的是为了创建makefile文件
. / configure \
-- prefix=/ usr/ local/ nginx \
-- pid- path=/ var / run/ nginx/ nginx. pid \
-- lock- path=/ var / lock/ nginx. lock \
-- error- log- path=/ var / log/ nginx/ error. log \
-- http- log- path=/ var / log/ nginx/ access. log \
-- with- http_gzip_static_module \
-- http- client- body- temp- path=/ var / temp/ nginx/ client \
-- http- proxy- temp- path=/ var / temp/ nginx/ proxy \
-- http- fastcgi- temp- path=/ var / temp/ nginx/ fastcgi \
-- http- uwsgi- temp- path=/ var / temp/ nginx/ uwsgi \
-- http- scgi- temp- path=/ var / temp/ nginx/ scgi
6.编译
make
7.安装
make install
8.查找Nginx安装目录
whereis nginx
9.进去Nginx的sbin目录启动
/ usr/ local/ nginx/ sbin/ nginx
10.通过浏览器输入服务器IP 出现下面html
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx. org.
Commercial support is available at nginx. com.
Thank you for using nginx.