Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,其特点是占有内存少,并发能力强.
cd /usr/local/ 创建nginx文件夹
mkdir nginx - cd nginx
- tar -zxvf nginx-1.23.1.tar.gz
cd nginx-1.23.1/ - ./configure --- 用来检测安装平台的目标特征
- make --- 用来编译( 从Makefile中读取指令,然后编译)
- make install --- 用来安装( 从Makefile中读取指令,安装到指定的位置)
- cd /usr/local/nginx/conf
-
- vim nginx.conf
-
- worker_processes 1; ##定义nginx子进程数量 1
-
- events { ##事务控制
- worker_connections 1024; #每个工作进程,允许的链接数1024
- }
-
-
- http {
- include mime.types; #默认读取文件
- default_type application/octet-stream; #处理方式
-
-
-
- sendfile on; #sendfile方式传输文件
-
- keepalive_timeout 65; #连接超时时间
-
- server {
- listen 7022; #前端监听端口
- server_name _; #主机名
-
- root /var/www/webpublish/test/page; #静态文件位置
- add_header X-Frame-Options SAMEORIGIN;
-
- location / {
-
- }
- location /newapi {。 #访问newapi时转到这个位置
- proxy_pass http://127.0.0.1:7021/; #代理的服务端地址
- }
-
- error_page 500 502 503 504 /50x.html; #通过请求返回的状态码,跳转uri。
- location = /50x.html {
- root html;
- }
-
-
- }
-
-
-
-
-
- }
- #进入目录
- cd /usr/local/nginx/sbin
-
- #启动命令
- ./nginx
- #停止命令
- ./nginx -s stop
- #重启命令
- ./nginx -s reload
开机自启
- vi /etc/rc.d/rc.local
-
-
-
- #在最下面添加
- /usr/local/nginx/sbin/nginx