一。 nginx安装
在虚拟机需要关闭防火墙,在服务器需要在安全组开启相应的端口。
systemctl status firewalld.service#(查看状态)
systemctl stop firewalld.service #关闭
systemctl disable firewalld.service #禁止
安装四个编译插件
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
安装步骤
- 直接下载.tar.gz安装包
https://nginx.org/en/download.html - 上传到自己的目录,比如/usr/local/software
- 解压缩
tar -zxvf nginx-1.20.2.tar.gz
cd nginx-1.20.2
- 配置
./configure --prefix=/usr/local/nginx
- 编译并且安装
make & make install
- 查看nginx安装路径
whereis nginx
- 加入系统服务
vim /etc/systemd/system/nginx.service
[Unit]
Description=nginx service
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
- 重新加载systemd并启动服务查看状态
systemctl damon-reload
systemctl start nginx
systemctl enable nginx
systemctl status nginx
- 查看进程
ps -aux | grep nginx
二. nginx进程
nginx有有主进程和work进程之分
三 nginx配置
配置文件在/usr/local/nginx/conf/nginx.conf下
- 配置模式连接数