Nginx--基础知识点--4--nginx安装

1 安装依赖

# 查看依赖是否已安装
yum list installed | grep -E "gcc|pcre-devel|zlib-devel|openssl|openssl-devel"
# 安装所有未安装的依赖
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel

2 下载包

# 下载nginx包
wget http://nginx.org/download/nginx-1.20.2.tar.gz
# 下载echo模块包
wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz

3 解压缩

# 解压缩nginx包,位置随意
tar -zxvf nginx-1.20.2.tar.gz
# 解压缩echo模块包,位置随意
tar -zxvf v0.61.tar.gz

4 编译nginx

进入nginx解压目录执行:

./configure --add-module=echo模块的解压目录

make && make install

5 启动与查看

# 检查配置文件是否正常
/usr/local/nginx/sbin/nginx -t 
# 启动nginx
/usr/local/nginx/sbin/nginx 
# 查看nginx版本
/usr/local/nginx/sbin/nginx -V

6 添加环境变量

# /etc/profile最后加入
export PATH=/usr/local/nginx/sbin:$PATH
# 重新加载环境变量
source /etc/profile

7 测试

7.1 测试nginx是否启动成功

curl http://localhost

7.2 测试echo

# nginx.conf加入
location /hello_world {
	echo "hello world";
}
nginx -s reload
curl http://localhost/hello_world
上一篇:本地idea-chisel开发环境搭建:


下一篇:为什么 JavaScript 会在移动端中胜出?