一、Linux安装Nginx
1、安装依赖
- yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2、下载解压
- cd /usr/local
- mkdir nginx
- cd nginx
- wget http://nginx.org/download/nginx-1.23.2.tar.gz
- tar -xvf nginx-1.23.2.tar.gz
3、安装
- cd /usr/local/nginx/nginx-1.23.2
//执行命令 安装ssl证书 添加依赖模块 ./configure --with-http_stub_status_module --with-http_ssl_module
- make
- make install
4、改配置、起服务
- vi /conf/nginx.conf 参看配置
- ./nginx …/conf/nginx.conf
5、开放端口:
- firewall-cmd --zone=public --add-port=8880/tcp --permanent
*firewall-cmd --reload
防火墙
- 开启防火墙 systemctl start firewalld
- 防火墙装状态 systemctl status firewalld
- 关闭防火墙 systemctl stop firewalld
- 关闭端口 firewall-cmd --zone=public --remove-port=25/tcp --permanent
Windows安装Nginx
Nginx使用
Linux命令
nginx配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream ecif {
server 192.168.56.10:8078 weight=1;
server 192.168.56.10:8079 weight=1;
}
server {
listen 8880;
server_name localhost;
location /api/ {
proxy_pass http://ecif/api/;
}
location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|js|css)$ {
proxy_pass http://ecif;
}
}
}