700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 关于Nginx的配置文件niginx.conf的中文详解

关于Nginx的配置文件niginx.conf的中文详解

时间:2020-06-06 08:56:21

相关推荐

关于Nginx的配置文件niginx.conf的中文详解

每次都要备份,索性直接写个详细点的备注然后留作备份了,纯手打,nginx版本为1.19.0

#配置worker进程运行用户,nobody是一个linux用户,一般用于启动程序,没有密码#user nobody;#配置工作进程数目,根据硬件调整,通常等于CPU数量或者二倍CPU的数量worker_processes 1;#配置全局错误日志及类型,[debug|info|notice|warn|error/|crit],默认为error#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#配置进程pid文件#pid logs/nginx.pid;###===============================#配置工作模式和连接数events {# 配置每个worker进程连接数上限,最大值为65535(最大连接数=连接数*进程数)worker_connections 1024;}###===============================#配置Http服务器,利用它的反向代理功能提供负载均衡支持http {#配置nginx支持哪些多媒体类型,可以在conf/mime.types查看支持哪些多媒体类型include 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日志及其存放路径,并使用上面定义的日志格式,如果打开该选项需要将上面的日志格式开启#access_log logs/access.log main;#开启高效文件传输模式sendfile on;#防止网络阻塞#tcp_nopushon;# 长连接超时时间,单位是秒#keepalive_timeout 0;keepalive_timeout 65;#开启gzip压缩输出,提升性能 #gzip on;###--------------------------#配置虚拟主机,一个http中可以有若干个serverserver {#配置监听端口listen 80;#配置服务名#一个http中可以有若干个server,但是每个server的端口和服务名字不能一样server_name localhost;#配置字符集#charset koi8-r;#配置本虚拟主机的访问日志#access_log logs/host.access.log main;#默认的匹配斜杠/的请求,当访问路径中有/,会被该location匹配到并进行处理location / {#root是配置服务器的默认网站根目录位置,默认为nginx安装主目录下的html目录root html;#配置首页文件的名称index index.html index.htm;}#配置404页面#error_page 404 /404.html;# 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服务# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificatecert.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;# }#}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。