Centos 安装 nginx
1、下载nginx源码
a)wget https://nginx.org/download/nginx-1.21.1.tar.gz
2、解压
a)tar -xvf nginx-1.21.1.tar.gz
3、编译
a)cd 进入解压后的nginx目录
b)配置ssl模块 ./configure --with-http_ssl_module
报错信息:
./configure: error: the HTTP rewrite module requires the PCRE library.
需要安装库:
yum -y install pcre-devel openssl openssl-devel
c)编译 执行make命令
d)安装 执行 make install 命令
e)安装成功后,nginx的主目录为 /usr/local/nginx
f)cd /usr/local/nginx/ 进入nginx主目录进行配置操作
g)编辑nginx配置:
i.cd conf/
ii.vi nginx.conf
iii.通用配置:
修改工作进程数(4个) worker_processes 4;
配置多核cpu(4核) worker_cpu_affinity 0001 0010 0100 1000;
使用epoll事件模型 events {
use epoll;
worker_connections 1024;
}
开启gzip压缩 gzip on;
Server里配置项目位置 location / {