首页 / NGINX / nginx 配置小结
nginx 配置小结
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nginx 配置小结,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4096字,纯文字阅读大概需要6分钟。
内容图文
下载linux版本的nginx
要么直接在linux中下载
要么在网站先下载
download
然后下载
两种方式
装nginx之前 你需要在linux上面装gcc openss pcre zlib库
如果想一次性安装,可以在命令行输入
yum install gcc openssl openssl-devel pcre pcre-devel zlib zlib-devel -y
如果想分开装:1gcc的安装
检查安装:yum list installed | grep gcc
执行安装:yum install gcc -y
2openssl的安装
检查安装: yum list installed |grep openssl
执行安装 yum install openssl openssl-devel -y
3 pcre库的安装
检查安装:yum list installed |grep pcre
执行安装:yum install pcre pcre-devel -y
4 zlib库的安装
检查安装:yum list installed |grep zlib
执行安装:yum install zlib zlib-devl -y
nginx中 conf的所有配置解析:
#user nobody; 配置worker进程运行用户
worker_processes 1; #配置工作进程数目,根据硬件调整,通常等于CPU数量或者2倍于CPU数量
#error_log logs/error.log; 配置全局错误日志及类型, [debug |info |notice |warn |error|crit] ,默认是error
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; 配置进程pid文件
###===============================================================================
#配置工作模式和连接数
events {
#use epoll; #epoll事件模型
worker_connections 1024; #配置每个worker进程连接数上限,nginx支持的总连接数就等于worker_processes * worker_connections
}
#配置http服务器,利用它的反向代理功能提供负载均衡支持
http {
include mime.types; #配置nginx支持哪些多媒体类型,可以在conf/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日志及存放路径,并使用上面定义的main日志格式
#access_log logs/access.log main;
sendfile on; #开启高效文件传输模式
#tcp_nopush on; #防止网路阻塞
#keepalive_timeout 0;
keepalive_timeout 65; #长连接超时时间,单位是秒
#gzip on;
####----------------------------------------
#配置虚拟主机
server {
listen 80; #配置监听端口
server_name localhost; #配置服务名
#charset koi8-r; #配置字符集
#access_log logs/host.access.log main; #配置本虚拟主机的访问日志
#默认的斜杠/的请求,当访问路径中有斜杠/,会被该location匹配到并进处理
location / {
#root html; #root是配置服务器的默认网站根目录位置,默认为nginx安装主目录下的html目录
#alias D:/nginx-1.17.3/nginx-1.17.3/html/images/;
alias D:/nginx-1.17.3/nginx-1.17.3/aa/images/;
#index index.html index.htm; #配置首页文件的名称
autoindex on;
}
#error_page 404 /404.html; #配置404页面
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html; #配置50x错误页面
#精确匹配
location = /50x.html {
root html;
}
#PHP 脚本请求全部转发到Apache处理
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#PHP 脚本请求全部转发到FastCGI处理
# 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;
#}
#禁止访问 .htaccess 文件
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
#配置另一个虚拟主机
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
#配置https服务,安全的网络传输协议,加密传输,端口443
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
内容总结
以上是互联网集市为您收集整理的nginx 配置小结全部内容,希望文章能够帮你解决nginx 配置小结所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。