Linux下Nginx基础应用
Nginx简介:
- Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
- Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好。
- Nginx不但是一个优秀Web服务软件,还具有反向代理负载均衡功能和缓存服务功能,与lvs负载均衡及Haproxy等专业代理软件相比,Nginx部署起来更为简单,方便;在缓存功能方面,它又类似于Squid等专业的缓存服务软件。
Nginx相对于传统的Apache服务的优缺点:
- (1) 作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率,这点使 Nginx 尤其受到虚拟主机提供商的欢迎。在高连接并发的情况下,Nginx是Apache服务器不错的替代品;
- (2) Nginx 配置简洁,Apach复杂;Nginx静态处理性能比Apache高3倍以上;Apache对PHP支持比较简单,Nginx需要配合其他后端用;Apache的组件比Nginx多;
- (3) apache是同步多进程模型,一个连接对应一个进程;nginx是异步的,多个连接(万级别)可以对应一个进程;
- (4) nginx处理静态文件好,耗费内存少,但apache目前也有它的优势,有很多丰富的特性,所以还需要搭配着来;当然如果能确定nginx就适合需求,那么使用nginx会是更经济的方式;
- (5) nginx的负载能力比apache高很多,而且nginx改完配置能-t测试一下配置有没有问题,apache重启的时候发现配置出错了,会很崩溃,改的时候都会非常小心翼翼现在看有好多集群站,前端nginx抗并发,后端apache集群,配合的也不错;
Nginx模块化体系结构:
nginx的模块根据其功能基本上可以分为以下几种类型:
- event module: 搭建了独立于操作系统的事件处理机制的框架,及提供了各具体事件的处理。包括ngx_events_module, ngx_event_core_module和ngx_epoll_module等。nginx具体使用何种事件处理模块,这依赖于具体的操作系统和编译选项。
- phase handler: 此类型的模块也被直接称为handler模块。主要负责处理客户端请求并产生待响应内容,比如ngx_http_static_module模块,负责客户端的静态页面请求处理并将对应的磁盘文件准备为响应内容输出。
- output filter: 也称为filter模块,主要是负责对输出的内容进行处理,可以对输出进行修改。例如,可以实现对输出的所有html页面增加预定义的footbar一类的工作,或者对输出的图片的URL进行替换之类的工作。
- upstream: upstream模块实现反向代理的功能,将真正的请求转发到后端服务器上,并从后端服务器上读取响应,发回客户端。upstream模块是一种特殊的handler,只不过响应内容不是真正由自己产生的,而是从后端服务器上读取的。
- load-balancer: 负载均衡模块,实现特定的算法,在众多的后端服务器中,选择一个服务器出来作为某个请求的转发服务器。
Nginx进程流程:
Nginx 服务器,正常运行过程中:
- 多进程:一个 Master 进程、多个 Worker 进程
- Master 进程:管理 Worker 进程
- 对外接口:接收外部的操作(信号)
- 对内转发:根据外部的操作的不同,通过信号管理 Worker
- 监控:监控 worker 进程的运行状态,worker 进程异常终止后,自动重启 worker 进程
- Worker 进程:所有 Worker 进程都是平等的
- 实际处理:网络请求,由 Worker 进程处理;
- Worker 进程数量:在 nginx.conf 中配置,一般设置为核心数,充分利用 CPU 资源,同时,避免进程数量过多,避免进程竞争 CPU 资源,增加上下文切换的损耗。
以下是常见http功能模块:
http类模块名 | 模块功能说明 | |
---|---|---|
ngx_http_core_module | http核心模块,对应配置文件中的http段,包含很多指令,如location指令 | |
ngx_http_access_module | 访问控制模块,控制网站用户对nginx的访问,对应于配置文件中的allow和deny等指令 | |
ngx_http_auth_basic_module | 通过用户名和密码认证的访问控制,如访问站点时需要数据用户名和密码,指令包括auth_basic和auth_basic_user_file | |
ngx_http_charset_module | 设置网页显示字符集。指令之一为charset,如charset utf-8 | |
ngx_http_fastcgi_module | fastcgi模块,和动态应用相关。该模块下有非常多的子模块。 | |
ngx_http_flv_module | 支持flv视频流的模块,如边下边播 | |
ngx_http_mp4_module | 同flv模块 | |
ngx_http_gzip_module | 压缩模块,用来压缩nginx返回的响应报文。一般只压缩纯文本内容,因为压缩比例非常大,而图片等不会去压缩 | |
ngx_http_image_filter_module | 和图片裁剪、缩略图相关模块,需要安装gd-devel才能编译该模块 | |
ngx_http_index_module | 定义将要被作为默认主页的文件,对应指令为index。"index index.html,index.php" | |
ngx_http_autoindex_module | 当index指令指定的主页文件不存在时,交给autoindex指令,将自动列出目录中的文件autoindex {on/off} | |
ngx_http_log_module | 和访问日志相关的模块,指令包括log_format和access_log | |
ngx_http_memcached_module | 和memcached相关的模块,用于从memcached服务器中获取相应响应数据 | |
ngx_http_proxy_module | 和代理相关,允许传送请求到其它服务器 | |
ngx_http_realip_module | 当nginx在反向代理的后端提供服务时,获取到真正的客户端地址,否则获取的是反向代理的IP地址 | |
ngx_http_referer_module | 实现防盗链功能的模块 | |
ngx_http_rewrite_module | 和URL地址重写相关的模块,需要安装pcre-devel才能编译安装该模块 | |
ngx_http_scgi_module | simple cgi,是cgi的替代品,和fastcgi类似,但更简单 | |
ngx_http_ssl_module | 提供ssl功能的模块,即实现HTTPS | |
ngx_http_stub_status_module | 获取nginx运行状态信息 | |
ngx_http_upstream | 和负载均衡相关模块 |
Nginx官方站点:
第一部分:CentOS7下使用YUM安装Nginx指定版本。
- # 准备环境
- [root@Server-01 ~]# cat /etc/redhat-release
- CentOS Linux release 7.5.1804 (Core)
- [root@Server-01 ~]# uname -a
- Linux Server-01 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- [root@Server-01 ~]# uname -r
- 3.10.0-862.el7.x86_64
- [root@Server-01 ~]# setenforce 0
- [root@Server-01 ~]# systemctl stop firewalld
- [root@Server-01 ~]# hostname -I
- 172.16.70.37
- # 安装nginx-1.14.2;目前(2021-07)最新版本为nginx-1.20.1
- [root@nginxServer ~]# rpm -ivh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.14.2-1.el7_4.ngx.x86_64.rpm
- [root@nginxServer ~]# nginx -v
- nginx version: nginx/1.14.2
- [root@nginxServer ~]# rpm -qa | grep nginx
- nginx-1.14.2-1.el7_4.ngx.x86_64
- [root@nginxServer ~]# rpm -ql nginx | less
- /etc/logrotate.d/nginx
- /etc/nginx # 相关配置文件存放目录
- /etc/nginx/conf.d
- /etc/nginx/conf.d/default.conf
- /etc/nginx/fastcgi_params
- /etc/nginx/koi-utf
- /etc/nginx/koi-win
- /etc/nginx/mime.types
- /etc/nginx/modules
- /etc/nginx/nginx.conf
- /etc/nginx/scgi_params
- /etc/nginx/uwsgi_params
- /etc/nginx/win-utf
- /etc/sysconfig/nginx
- /etc/sysconfig/nginx-debug
- /usr/lib/systemd/system/nginx-debug.service
- /usr/lib/systemd/system/nginx.service
- /usr/lib64/nginx
- /usr/lib64/nginx/modules
- /usr/libexec/initscripts/legacy-actions/nginx
- /usr/libexec/initscripts/legacy-actions/nginx/check-reload
- /usr/libexec/initscripts/legacy-actions/nginx/upgrade
- /usr/sbin/nginx
- /usr/sbin/nginx-debug
- /usr/share/doc/nginx-1.14.2
- /usr/share/doc/nginx-1.14.2/COPYRIGHT
- /usr/share/man/man8/nginx.8.gz
- /usr/share/nginx
- /usr/share/nginx/html # 默认站点存放目录
- /usr/share/nginx/html/50x.html
- /usr/share/nginx/html/index.html
- /var/cache/nginx
- /var/log/nginx # 日志文件存放目录
- -----------------------------------------------------------------------------
- # systemctl命令:
- 服务状态 systemctl status nginx
- 服务启动 systemctl start nginx
- 服务停止 systemctl stop nginx
- 服务重启 systemctl restart nginx
- # nginx命令语法及参数:
- [root@nginxServer ~]# nginx -h
- nginx version: nginx/1.14.2
- Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
- Options:
- -?,-h : this help
- -v : 输出版本号
- -V : 输出版本号以及编译选项
- -t : 检查配置文件的语法
- -T : 检查配置文件的语法并输出配置的内容
- -q : 静默模式,不输出任何信息
- -s signal : 向主进程发送信号:stop, quit, reopen, reload
- -p prefix : 设置nginx的basedir(默认为编译时的prefix)
- -c filename : 指定配置文件
- -g directives : 提前设置全局指令
- -------------------------------------------------------------------------------
- # 启动,并设置开机启动
- [root@nginxServer ~]# systemctl start nginx && systemctl enable nginx
- Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
- [root@nginxServer ~]# ps -ef |grep nginx
- root 1466 1 0 16:54 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
- nginx 1467 1466 0 16:54 ? 00:00:00 nginx: worker process
- root 1486 1178 0 16:54 pts/0 00:00:00 grep --color=auto nginx
- [root@nginxServer ~]# netstat -nutlp | grep nginx
- tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1466/nginx: master
- Web检测测试效果。
- Nginx默认配置文件解析:
- [root@nginxServer ~]# cat /etc/nginx/nginx.conf
- user nginx; # 配置用户或组
- worker_processes 1; # worker允许生成的进程数
- error_log /var/log/nginx/error.log warn; # 制定日志路径,级别。这个设置可以放入全局块,http块,server块,级别以此为:debug|info|notice|warn|error|crit|alert|emerg
- pid /var/run/nginx.pid; # 指定nginx进程运行文件存放位置
- events { # 事件区块
- worker_connections 1024; # 每个worker进程支持的最大连接数
- }
- http { # http区块
- include /etc/nginx/mime.types; # 支持的媒体类型库文件包含
- default_type application/octet-stream; # 默认媒体类型
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- access_log /var/log/nginx/access.log main; # 默认log格式
- sendfile on; # 允许sendfile方式传输文件,可以在http块,server块,location块
- #tcp_nopush on;
- keepalive_timeout 65; # 连接超时时间,可以在http块,server块,location块
- #gzip on;
- include /etc/nginx/conf.d/*.conf; # 生效包含自定义配置
- }
- [root@nginxServer nginx]# cat conf.d/default.conf
- server { # 网站配置区域
- listen 80; # 提供服务的端口,默认80
- server_name localhost; # 提供服务的域名主机名
- #charset koi8-r;
- #access_log /var/log/nginx/host.access.log main;
- location / { # location区块开始
- root /usr/share/nginx/html; # 站点的根目录(相对与nginx安装目录)
- index index.html index.htm; # 默认的首页文件,多个用空格分开
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html; # 出现对应的http状态码时,使用50x.html回应客户
- location = /50x.html { # location区块开始,访问50x.html
- root /usr/share/nginx/html; # 指定对应的站点目录为html
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
- -----------------------------------------------------------
- # 整个nginx配置文件的核心框架如下
- worker_processes 1;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- server {
- listen 80;
- server_name localhost;
- location / {
- root html;
- index index.html index.htm;
- }
- }
- }
第二部分:设置虚拟主机。
- nginx使用server容器定义一个虚拟主机。在nginx中,没有严格区分基于IP和基于名称的虚拟主机,它们通过listen指令和server_name指令结合起来形成不同的虚拟主机。
- # 配置文件目录结构
- [root@nginxServer ~]# tree /etc/nginx/
- /etc/nginx/
- ├── conf.d
- │ ├── default.conf
- ├── fastcgi_params
- ├── koi-utf
- ├── koi-win
- ├── mime.types
- ├── modules -> ../../usr/lib64/nginx/modules
- ├── nginx.conf
- ├── scgi_params
- ├── uwsgi_params
- └── win-utf
- 2 directories, 10 files
- 说明:其中".default"后缀的是对应前缀配置文件的备份配置文件,".params"是对应前缀的参数文件。
- # 创建站点目录及站点内容
- [root@nginxServer ~]# for i in {1..3}; do mkdir -p /data/web/nginx/www$i; echo "Mysite-$i www$i.nginx.com" > /data/web/nginx/www$i/index.html; done
- [root@nginxServer ~]# tree /data/web/nginx/
- /data/web/nginx/
- ├── www1
- │ └── index.html
- ├── www2
- │ └── index.html
- └── www3
- └── index.html
- 3 directories, 3 files
- [root@nginxServer ~]# cat /data/web/nginx/www*/*
- Mysite-1 www1.nginx.com
- Mysite-2 www2.nginx.com
- Mysite-3 www3.nginx.com
- [root@nginxServer ~]# cd /etc/nginx/conf.d/
- [root@nginxServer conf.d]# mv default.conf default.conf_bak
- # 新增虚拟主机配置文件
- [root@nginxServer conf.d]# vim vhosts.conf
- # 基于端口port
- server {
- listen 8081;
- server_name www1.nginx.com;
- location / {
- root /data/web/nginx/www1;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www1;
- }
- }
- server {
- listen 8082;
- server_name www2.nginx.com;
- location / {
- root /data/web/nginx/www2;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www2;
- }
- }
- # 基于域名FQDN
- server {
- listen 80;
- server_name www1.nginx.com;
- location / {
- root /data/web/nginx/www1;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www1;
- }
- }
- server {
- listen 80;
- server_name www3.nginx.com;
- location / {
- root /data/web/nginx/www3;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www3;
- }
- }
- #基于IP地址
- server {
- listen 80;
- server_name 172.16.70.37;
- location / {
- root /data/web/nginx/www2;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www2;
- }
- }
- server {
- listen 80;
- server_name 172.16.70.38;
- location / {
- root /data/web/nginx/www3;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www3;
- }
- }
- # 新增nginx状态信息配置文件
- [root@nginxServer conf.d]# vim status.conf
- # State information
- server{
- listen 80;
- server_name status.nginx.com;
- location / {
- stub_status on;
- access_log off;
- }
- }
- # 基于域名,添加地址解析
- [root@nginxServer conf.d]# echo '172.16.70.37 www1.nginx.com www2.nginx.com www3.nginx.com status.nginx.com' >> /etc/hosts
- # 基于IP,添加IP地址
- [root@nginxServer conf.d]# ip addr add 172.16.70.38/24 dev ens33
- [root@nginxServer conf.d]# ip addr | grep ens33
- 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
- inet 172.16.70.37/24 brd 172.16.70.255 scope global noprefixroute dynamic ens33
- inet 172.16.70.38/24 scope global secondary ens33
- [root@nginxServer conf.d]# ping 172.16.70.38 -c2
- PING 172.16.70.38 (172.16.70.38) 56(84) bytes of data.
- 64 bytes from 172.16.70.38: icmp_seq=1 ttl=64 time=0.015 ms
- 64 bytes from 172.16.70.38: icmp_seq=2 ttl=64 time=0.059 ms
- --- 172.16.70.38 ping statistics ---
- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms
- rtt min/avg/max/mdev = 0.015/0.037/0.059/0.022 ms
- [root@nginxServer conf.d]# nginx -t # 检测配置文件语法
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- [root@nginxServer conf.d]# nginx -s reload # 重载nginx
- [root@nginxServer conf.d]# netstat -ntupl | grep nginx
- tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1466/nginx: master
- tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 1466/nginx: master
- tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 1466/nginx: master
- # 检测测试结果
- [root@nginxServer conf.d]# hostname -I
- 172.16.70.37
- # 基于端口
- [root@nginxServer conf.d]# curl 172.16.70.37:8081
- Mysite-1 www1.nginx.com
- [root@nginxServer conf.d]# curl 172.16.70.37:8082
- Mysite-2 www2.nginx.com
- # 基于域名
- [root@nginxServer conf.d]# curl www1.nginx.com
- Mysite-1 www1.nginx.com
- [root@nginxServer conf.d]# curl www3.nginx.com
- Mysite-3 www3.nginx.com
- # 基于IP
- [root@nginxServer conf.d]# curl 172.16.70.37
- Mysite-2 www2.nginx.com
- [root@nginxServer conf.d]# curl 172.16.70.38
- Mysite-3 www3.nginx.com
- # 显示状态结果
- [root@nginxServer conf.d]# curl status.nginx.com
- Active connections: 1
- server accepts handled requests
- 105 105 116
- Reading: 0 Writing: 1 Waiting: 0
- 说明:
- Active connections 当前nginx正处理的活动连接数
- server 总共处理的连接数
- accepts 成功创建握手次数
- handled requests 总共处理请求数(平均每次握手处理了1.3个数据请求)
- Reading nginx读取到客户端的Header信息数
- Writing nginx返回给客户端的Header信息数
- Waiting nginx已经处理完正在等候下一次请求指令的驻留连接。在开启keep-alive的情况下,这个值等于active - (reading+writing)
第三部分:Nginx Web认证
- 基于用户认证。即需要输入用户名和密码才能访问站点的功能为web身份认证功能。nginx中由ngx_http_auth_basic_module模块提供该功能。指令包括auth_basic和auth_basic_user_file。这两个指令可以在http根段、server段、location段使用。
- [root@nginxServer conf.d]# pwd
- /etc/nginx/conf.d
- [root@nginxServer conf.d]# vim vhosts.conf
- server {
- listen 80;
- server_name www1.nginx.com;
- location / {
- root /data/web/nginx/www1;
- index index.html index.htm;
- auth_basic "Auth your name";
- auth_basic_user_file /etc/nginx/.ngxpasswd;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/web/nginx/www1;
- }
- }
- # htpasswd命令由httpd-tools所提供
- [root@nginxServer conf.d]# yum install -y httpd-tools
- [root@nginxServer conf.d]# htpasswd -c -b -m /etc/nginx/.ngxpasswd user1 user1
- Adding password for user user1
- [root@nginxServer conf.d]# htpasswd -b -m /etc/nginx/.ngxpasswd user2 user2
- Adding password for user user2
- 说明:
- -c表示创建密码文件,只能为第一个用户使用该选项,否则后面使用会覆盖前面已经创建过的
- -b选项是表示batch模式,不用交互输入密码
- -m表示强制使用md5
- [root@nginxServer conf.d]# cat /etc/nginx/.ngxpasswd
- user1:$apr1$MaM8PAS.$FjeZesqyESHjUyUarao.q/
- user2:$apr1$3Tvnt.Kp$ysOph6mgMyTHaqgLy6fsH1
- [root@nginxServer conf.d]# nginx -t
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- [root@nginxServer conf.d]# nginx -s reload
- 检测测试结果。
WIN10的hosts文件添加解析:将'172.16.70.37 www1.nginx.com www2.nginx.com www3.nginx.com'添加到C:\Windows\System32\drivers\etc\hosts
Nginx访问日志轮询切割:
- 默认情况下Nginx会把所有的访问日志生成到一个指定的访问日志文件access.log里,但这样一来,时间长了就会导致日志个头很大,不利于日志的分析和处理,因此,有必要对Nginx日志,按天或按小时进行切割,使其分成不同的文件保存。
- [root@nginxServer nginx]# pwd
- /etc/nginx
- [root@nginxServer nginx]# cat cut_nginx_log.sh
- #!/bin/bash
- #日志切割脚本可挂定时任务,每天00点整执行
- Dateformat=`date +%Y%m%d`
- Nginxlogdir="/var/log/nginx"
- Logname="access"
- [ -d $Nginxlogdir ] && cd $Nginxlogdir || exit 1
- [ -f ${Logname}.log ] || exit 1
- /usr/bin/mv ${Logname}.log ${Logname}.log_${Dateformat}
- /usr/sbin/nginx -s reload
- # 新增计划任务
- [root@nginxServer nginx]# cat /etc/cron.d/cut_nginx_log.cron
- #cut nginx access log
- 00 00 * * * root /usr/bin/bash /etc/nginx/cut_nginx_log.sh >/dev/null 2>&
Linux下Nginx基础应用的更多相关文章
- 【转】Linux下nginx配置https协议访问的方法
一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...
- VMware Linux 下 Nginx
负载 VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三) Weiseditor 2014-11-26 23:42 阅读:1 评论 ...
- VMware Linux 下 Nginx 安装配置 - nginx.conf 配置 [负载两个 Tomcat] (三)
首先启动Nginx 1. 相关浏览 两个 Tomcat 配置: VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二) Nginx 安装配置启动: VMware Linu ...
- VMware Linux 下 Nginx 安装配置 - Tomcat 配置 (二)
准备工作 相关浏览: VMware Linux 下 Nginx 安装配置 (一) 1. 选在 /usr/local/ 下创建 softs 文件夹,通过 ftp 命令 把 apache-tomcat-7 ...
- Linux下nginx编译安装教程和编译参数详解
这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...
- linux下nginx+php+mysql 自助环境搭建
++++++++++++++++++++++++++++++++++++++++++++++linux下nginx+php+mysql环境搭建+++++++++++++++++++++++++++++ ...
- linux下nginx结合keepalived实现主从切换的配置
linux下nginx结合keepalived实现主从切换的配置 解决方法: 实现一个主nginx宕机,请求转到另一个nginx中. 1.确保两台nginx已启动,假如端口分别是192.168.0 ...
- linux下nginx服务器域名指定目录
一般,域名指定ip之后,需要在ip所在的机器去指定相应站点的目录,否则域名会不起作用: 下面说说linux下的nginx服务器指定目录的细节: 域名绑定目录的配置文件都放到这里: /usr/local ...
- Linux下Nginx的安装与配置
安装前需要安装pcre:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/1.解压缩: tar xjpf pcre-7.8.tar.b ...
随机推荐
- Nginx为什么能快到根本停不下来?
Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名.本文从底层原理分析 Nginx 为什么这么快! Nginx 的进程模型 Nginx 服务器,正常运行过程中: 多进程:一个 M ...
- 支持向量机(SVM)之硬阈值
支持向量机 ( support vector machine, SVM ) 是使用超平面来对给定的 p 维向量进行分类的非概率二元线性分类器. 一.超平面 ( hyperplane ) 在一个p维的输 ...
- Golang学习(用代码来学习) - 第四篇
/** 一个用来进行go routine的函数 */ func print_something(msg string){ for i:= 0;i < 5;i++{ time.Sleep(1 * ...
- excel VBA构造正则函数(单参数)
Function zhengze(Rng As Range) Set regx = CreateObject("vbscript.regexp")With regx .Gl ...
- 『心善渊』Selenium3.0基础 — 17、Selenium操作浏览器窗口的滚动条
目录 1.为什么操作滚动条 2.Selenium如何操作滚动条 3.Selenium操作滚动条方法 4.操作滚动条示例 5.下拉至聚焦元素的位置 (1)实现步骤: (2)实现示例: 1.为什么操作滚动 ...
- 查看JVM中的线程名
实例说明 在Java虚拟机中(JVM):除了用户创建的线程,还有服务于用户线程的其他线程.它们根据不同的用途被分到不同的组中进行管理.本实例将演示JVM中线程的名字及其所在组的名称. 关键技术 线程组 ...
- sqlite用法总结
p.p1 { margin: 0; font: 16px "Helvetica Neue"; color: rgba(0, 0, 255, 1) } p.p2 { margin: ...
- Redis数据库 常用的基本操作
一.redis数据库操作 redis数据库默认有16个数据库[0-15],默认进入的是0库. select 数据库名 :切换数据库. keys * :查看所有的键. expire 键 秒数:设置过 ...
- s3cmd的使用
目录 1. 安装s3cmd 2. 配置s3cmd 3. 使用s3cmd [前言] s3cmd 是用于创建S3桶,上传,检索和管理数据到对象存储命令行实用程序. 本文将指导linux下安装s3cmd程序 ...
- sort,wc,uniq 排序与统计命令
sort命令 语法:sort [parameter] [file or stdin]参数: -f:忽略大小写的差异,例如A和a视为编码相同 -b:忽略最前面的空格符部分 -n:使用"纯数字& ...