一,服务介绍
是一个开源,支持高性能,高并发的www服务和代理服务软件,占用资源少,且功能丰富而逐渐流行起来,
二,服务功能以及特性
nginx重要特性
他所具备的其他www服务特性如下:
企业面试时需要解答如下步骤 nginx http服务器的特色及优点
nginx软件的主要企业功能应用
三,服务区别
apache:
nginx:
四,epoll模型和select模型区别形象比喻介绍
五,如何根据企业场景正确选择web服务器
六,linux系统安装软件的多种方法
1.rpm安装
2.yum安装
3.编译安装(C语言源码,编译二进制等)
4.企业定制化制作rpm包,搭建yum仓库,把我定制的rpm包放到yum仓库,进行yum安装
七,安装nginxweb服务实战
1.安装nginx做需的pcre库
pcre中文perl监控正则表达式,安装pcre库就是为了使nginx支持具备URL重新功能的rewirte模块,如果不安装pcre库,则nginx无法使用rewrite模块功能,nginx的rewrite模块功能几乎是企业应用的必须,安装过程如下:
a,yum -y install pcre pcre-devel
b.yum -y install openssl openssl-devel
c.wegt xxx nginx-xxx.tar.gz
d.tar xf nginx-xxx.tar.gz
e.cd nginx-xxx
f.useradd www -s /sbin/nologin -M
./configure --help
g./configure --user=www --group=www --prefix=/application/nginx-1.8.0/ --with-http_ssl_module --with-http_stub_status_module
h.echo $0 确定是否安装成功否
make
make install
ln -s /application/nginx-1.8.0/ /application/nginx
八,自定义站定目录以及简单编写开发网页内容详解
egrep -v "^$|#" nginx.conf.default >nginx.conf 把开头是$|#去掉
下面代表一个网站
server {
listen 80;
server_name www.etiantian.com; ###域名
location / { #安装根目录
root html; #安装相对路径
index index.html index.htm; #默认打开文件
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
下面代表php安装情况
sbin 执行文件
log 日志文件
html 站点目录
九,nginx常用模块介绍
核心模块
标准模块
十,nginx主配置文件默认参数详解
worker_processes 1; #---------------------------------->>>main区,nginx核心功能模块 进程数量1,worker数量很多
events {
worker_connections 1024; #---------------------------------->>> 一个worker最大服务数量,同时可以接的数量,最大并发数worker*
} #---------------------------------->>>events区,nginx核心功能模块
http { #---------------------------------->>>http区,nginx核心功能模块
include mime.types; #---------------------------------->>>include包含,这个配置文件包含mime.types
default_type application/octet-stream;
sendfile on; #---------------------------------->>>开启高效传输模式,优化会讲
keepalive_timeout 65; #---------------------------------->>>超时时间,链接时间
server { #---------------------------------->>>一个server对应一个网站,
listen 80; #---------------------------------->>>端口必须有,每个server都有
server_name localhost; #---------------------------------->>>域名必须有,每个server都有
location / { #---------------------------------->>>没有做任何匹配,默认找这个文件对应的内容
root html;
index index.html index.htm;
}
location /50z.html{ #---------------------------------->>>如果匹配上了,默认就走这个文件
root html;
}
error_page 500 502 503 504 /50x.html; #---------------------------------->>>出现错误,找这个文件,优雅匹配
location = /50x.html {
root html;
}
}
}
十一,虚拟主机概念和类型介绍
所谓虚拟主机,再web服务里就是一个独立的网站站点,这个站点对应独立的域名,也可能是IP或则端口,具有独立的程序或资源目录,可以独立的对外提供服务供用户访问,这个独立的站点再配置上有一定格式的标签标记,
一个web服务里可以有多个虚拟主机标签对,同时支持多个虚拟主机站点
例子:blog.51cto.com www.51cto.com edu.51cto.com home.51cto.com
十二,多种类型的虚拟主机详细介绍
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
}
server {
listen 80;
server_name bbs.etiantian.org;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 80;
server_name blog.etiantian.org;
autoindex on; #可以避免403错误而且可以提供以恶喜爱啊
location / {
root html/blog;
index index.html index.htm;
}
}
}
具体流程:
dns解析
请求报文请求头里面有host,
服务器接收到端口和域名,
然后就从上往下走,
因为只有一个localtion,
就走默认的,/读配置,走下面配置,
如果都没有就返回403错误
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
}
server {
listen 81;
server_name www.etiantian.org;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 82;
server_name www.etiantian.org;
autoindex on; #可以避免403错误而且可以提供以恶喜爱啊
location / {
root html/blog;
index index.html index.htm;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 192.168.1.9;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
}
server {
listen 192.168.1.10;
server_name www.etiantian.org;
location / {
root html/bbs;
index index.html index.htm;
}
}
server {
listen 192.168.1.11;
server_name www.etiantian.org;
autoindex on; #可以避免403错误而且可以提供以恶喜爱啊
location / {
root html/blog;
index index.html index.htm;
}
}
}
b.
虚拟主机配置步骤检查及检测策略-配置文件优化等
配置ngixn虚拟主机别名以及别人企业场景的应用说明
nginx状态模块详解与实战
nginx日志及错误日志详解
ngixn访问日志介绍与实践
nginx日志轮询切割实战
nginxlocaltion重要语法讲解及实践检验
nginxlocaltion重要时间及结论总结
nginxlocaltion举例实践
nginxrewrite介绍及语法讲解
nginxrewrite标签及正则介绍
ngixnrewrite实战案例301及url跳转
nginx用户访问呢及密码验证实战
nginx及apache出现状态403问题的解决方案汇总介绍
lnmp流行架构介绍及原理流程讲解
原文:https://www.cnblogs.com/qiulovelinux/p/10417477.html