Nginx: 是一个高性能HTTP 和 反向署理 服务器、IMAP、POP3、SMTP 邮件署理服务器。
特点: 高并发响应性能非常好,官方Nginx处置处罚静态文件并发5w/s;负载均衡及反向署理性能非常强;可对后端服务举行康健查抄;支持PHP cgi方式和FastCGI方式;可以作为缓存服务器、邮件署理服务器;支持热摆设(在线升级)。
摆设nginx:
yum摆设:
- # 设置堆栈:// vim /etc/yum.repos.d/nginx.repo# 安装:// yum install nginx -y### 源码摆设:下载nginx源码包:// wget http://nginx.org/download/nginx-1.18.0.tar.gz# 解压:// tar xf nginx-1.18.0.tar.gz# 办理依赖:// yum install pcre-devel zlib-devel -y# 预编译:cd nginx-1.18.0// ./configure --prefix=/usr/local/nginx# 编译、安装:make && make install# 启动服务:// /usr/local/nginx/sbin/nginx# 查察进程与端口:// ps -ef | grep nginx
复制代码 nginx常用指令:
- // /usr/local/nginx/sbin/nginx -? nginx version: nginx/1.18.0Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-pprefix] [-g directives]Options:-?,-h : this help# 显示nginx版本-v : show version and exit# 显示nginx版本以及nginx预编译参数-V : show version and configure options thenexit# 测试nginx设置文件语法问题-t : test configuration and exit# 测试nginx设置文件语法问题,而且还可以使用重定向举行设置文件备份-T : test configuration, dump it and exit# 静默模式启动nginx服务:-q : suppress non-error messages duringconfiguration testing# 给master进程发送信号,包罗立即停止,优雅停止,重载日志文件,重载设置文件。-s signal : send signal to a master process: stop,quit, reopen, reload# 设置nginx主目次:-p prefix : set prefix path (default:/usr/local/nginx/)# 设置nginx启动的设置文件-c filename : set configuration file (default:conf/nginx.conf)# 设置nginx全局变量-g directives : set global directives out ofconfiguration file
复制代码 设置nginx虚拟主机:
设置虚拟主机常见方式: 基于多域名设置虚拟主机; 基于多端口设置虚拟主机; 基于多IP设置虚拟主机;基于多域名设置虚拟主机
- // vim /usr/local/nginx/conf/nginx.conf...keepalive_timeout 65;include vhost/*.conf;server { listen 80; server_name localhost;...
- // mkdir -p /usr/local/nginx/conf/vhost// vim /usr/local/nginx/conf/vhost/www.jfedu.net.confserver { server_name www.jfedu.net; root /usr/local/nginx/html/www; location / { index index.html; }}// vim /usr/local/nginx/conf/vhost/blog.jfedu.net.confserver { server_name blog.jfedu.net; root /usr/local/nginx/html/blog; location / { index index.html; }}# 创建目次:
- // mkdir -p /usr/local/nginx/html/{www,blog}# 创建测试页面:
- // echo "this is www page" > /usr/local/nginx/html/www/index.html// echo "this is blog page" > /usr/local/nginx/html/blog/index.html# 创建本地分析:
- // echo "192.168.75.124 www.jfedu.net blog.jfedu.net" > /etc/hosts重启服务,访问测试:
- // cd /usr/local/nginx/sbin/nginx -s reload// curl www.jfedu.netthis is www page// curl blog.jfedu.netthis is blog page
复制代码 来源:https://blog.csdn.net/apple_54172342/article/details/112059136
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |