1、首先关闭linux的防火墙,查看linux防火墙博客 https://www.cnblogs.com/liuyi-clover/p/9755966.html
2、给nginx配置安装目录
mkdir /usr/local/nginx
3、解压已经上传到nginx目录中的压缩包
cd /usr/local/nginx
tar -zxvf nginx-1.16.0.tar.gz
4、执行 ./configure命令
cd nginx-1.16.0
yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel
./configure
5、make 编译
编译的过程是把各种语言写的源码文件,变成可执行文件和各种库文件
cd /usr/local/nginx/nginx-1.16.0
make
6、make install安装
把这些编译出来的可执行文件和库文件复制到合适的地方
make install
7、启动nginx服务
cd /usr/local/nginx/sbin
./nginx
8、看nginx服务是否启动
ps -ef|grep nginx
9、关闭nginx:
worker_processes 4; error_log logs/error.log notice; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #Nginx服务配置,直接访问localhost:8080即可打开dist访问vue项目 #Linux下更改root目录为 /usr/local/dist/;即可 server { listen 8080; server_name localhost; location / { root C:/Users/Clover/Desktop/dist; index index.html index.htm; } location /api { proxy_pass http://106.12.140.159:8888/api; } location /bpi { proxy_pass http://cache.video.iqiyi.com/jp; } } }
11、nginx负载均衡常用配置
worker_processes 4; error_log logs/error.log notice; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream nacos{ server 192.168.232.110:8848 weight=8; server 192.168.232.111:8848 weight=10; } server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; } location /nacos { proxy_pass http://nacos; } } }
O(∩_∩)O开心就好O(∩_∩)O