centos7 nginx 安装

记录一下我在 centos7 安装 nginx,博主是安装在 /opt/nginx 目录下的

首先安装编译环境

yum install gcc gcc-c++

安装依赖:pcre && zlib && openss && nginx

不要跟我说什么手写加深记忆,老夫写代码就是ctrl c & ctrl v

    wget http://www.zlib.net/zlib-1.2.11.tar.gz
    wget http://nginx.org/download/nginx-1.8.1.tar.gz
    wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

PS:上面的内容博主下载在 /opt/nginx 目录下,你们自定义

解压依赖:pcre && zlib && openss && nginx

说一句 tar -xvf 比你的 tar -zxvf 要叼!

    tar -xvf pcre-8.38.tar.gz
    tar -xvf zlib-1.2.11.tar.gz
    tar -xvf openssl-1.0.2n.tar.gz
    tar -xvf nginx-1.8.1.tar.gz

安装:pcre && zlib && openss && nginx

pcre

# 进入 pcre 目录
cd pcre-8.38
# 执行 configure
./configure
# 安装
make && make install

zlib

# 进入 zlib 目录
cd zlib-1.2.11
# 执行 configure
./configure
# 安装
make && make install

openssl

# 进入目录
cd openssl-1.0.2n
# 执行 config
./config --prefix=/usr/local/openssl
# 安装
make && make install

nginx

# 进入目录
cd nginx-1.8.1
# 执行 configure 
./configure --prefix=/usr/local/nginx --with-pcre=/opt/nginx/pcre-8.41 --with-zlib=/opt/nginx/zlib-1.2.11 --with-openssl=/usr/local/openssl
# 安装
make && make install

最后启动 nginx

/usr/local/nginx/sbin/nginx

在浏览器输入你服务器的地址,如果出现以下画面,恭喜你,安装成功了!

image.png

记得开 80 端口!!!

你可能感兴趣的:(centos7 nginx 安装)