nginx学习(一)-nginx安装

主要命令

  1. 安装gcc环境,一般都已经安装
yum install gcc-c++

2.安装PCRE库,用于解析正则表达式

yum install -y pcre pcre-devel

3.zlib压缩和解压缩

yum install -y zlib zlib-devel

4.安装openSSL,用户HTTP安装传输,开启HTTPS

yum install -y openssl openssl-devel

步骤

1. 下载

下载页面 http://nginx.org/en/download.html


Mainline是开发版本, 一般安装 Stable

2.解压编译

需要解压然后编译

#解压
tar -zxvf nginx-xxxx.tar.gz 
# nginx 临时文件夹
mkdir /var/temp/nginx -p
# 编译, 这边是编译到nginx解压目录下build文件家,同时配置了两个第三方module
./configure --prefix=/root/software/nginx-1.20.2/build --add-module=/root/software/nginx-1.20.2/NGmodule/headers-more-nginx-module-0.33 --add-module=/root/software/nginx-1.20.2/NGmodule/nginx-rtmp-module-1.2.2
make
make install

一些重要的nginx配置项

配置举例 详情
--prefix 指定nginx安装目录
--pid-path 指定nginx的pid
--lock-path 锁定安装目录防止篡改
--error-log 错误日志
--http-log-path http日志
--with-http_gzip-static-module 启用gzip慕课,在线实时压缩输出视频流
--http-client-body-temp-path 指定客户端请求的临时目录
--http-proxy-temp-path proxy临时目录
--http-fastcgi-temp-path fastcgi临时目录
--http-uwsgi-temp-path uwsgi临时目录
--http-scgi-temp-path scgi临时目录

查询nginx 是否安装成功

查询nginx
whereis nginx 

几个主要命令

# 查询nginx 配置文件
nginx -V
#启动 
./nginx 
#重新装载配置
./nginx -s reload
#关闭
./nginx -s stop

有的时候会报403 forbidden错误,检查一下error.log 大概率是 没有权限。改一下nginx.conf中的用户
user nginx

posted @ 2022-04-06 21:40  别骂了,再骂拉黑  阅读(38)  评论(0)    收藏  举报