centos7 安装nginx服务器以及环境(阿里云|腾讯云)
centos7 安装nginx服务器以及环境
准备环境
1 阿里云虚拟机(vps)或 腾讯云虚拟机(vps)以及其他centos7系统虚拟机或者vps
2 安装了centos7版本的操作系统
依赖安装
1 gcc 安装
执行语句:
yum install gcc-c++
安装nginx需要到官网下载源码进行编译,由于nginx 使用C语言进行编译 所以需要安装gcc环境进行编译
2 PCRE pcre-devel 安装
执行语句:
yum install -y pcre pcre-devel
nginx的http模块需要使用PCRE解析正正则表达式,因此需要安装PCRE
3 zlib 安装
执行语句:
yum install -y zlib zlib-devel
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库
4 OpenSSL 安装
执行语句 :(yum install -y openssl openssl-devel)
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。
nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
官网下载安装包 (两种方法二选一)
手动下载(.tar.gz)
地址:
https://nginx.org/en/download.html
使用wget命令下载(.tar.gz)
如果没有安装wget,执行 yum install wget 安装
执行语句:
wget -c https://nginx.org/download/nginx-1.20.2.tar.gz
解压
1 手动从官网下载后需要远程工具传送到服务器安装包到安装目录
2 然后解压安装包
执行语句:
tar -zxvf nginx-1.20.2.tar.gz
nginx-1.20.2.tar.gz 是我下载的安装包 具体根据你下载的包决定
执行语句:
cd nginx-1.12.0
进入解压路径
配置
1 默认配置(推荐)
执行语句 (./configure)
2 自定义 (不推荐)
./configure
--prefix=/usr/local/nginx
--conf-path=/usr/local/nginx/conf/nginx.conf
--pid-path=/usr/local/nginx/conf/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
编译安装
执行语句:
make
执行语句:
make install
可使用
whereis nginx
查找安装路径
到这里就安装好了
具体配置见我的博客
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
二维码