nginx图片服务器

Nginx下载地址:http://nginx.org/en/download.html
下载完后,解压,并把它放到D:\nginx-1.6.1,双击nginx.exe即可运行nginx。可通http://127.0.0.1访问到nginx欢迎界面
也可在cmd中通过命令进行启停启动nginx:
start nginx //运行nginx
nginx -s stop // 停止nginx
nginx -s reload // 重新加载配置文件(如修改配置文件后,可通过该命令重新加载)
nginx -s quit // 退出nginx
nginx -v //可查nginx版本

在执行nginx命令时,出现了 windows nginx: [error] CreateFile() "logs/nginx.pid" failed 异常。原因是未指定
nginx.conf,指定该文件,启动命令如下:
D:\nginx-1.6.1>nginx -c D:\nginx-1.6.1\conf\nginx.conf

在本地建了一个D:\images文件夹,里面放了一张测试图片。
配置nginx.conf文件,配置文件内容如下:
#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
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 logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;


server {
listen 8089;#端口号
server_name localhost;#本机

charset utf-8;

#access_log logs/host.access.log main;

location ~ .*\.(gif|jpg|jpeg|png)$ {
expires 24h;
root D:/images/;#指定图片存放路径
access_log D:/nginx-1.6.1/logs/log_test.log;#图片路径
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path D:/images/;#图片路径
proxy_redirect off;

proxy_set_header Host 127.0.0.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 40k;
proxy_buffers 40 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
if ( !-e $request_filename)
{
proxy_pass http://127.0.0.1:8089;#代理访问地址
}
}

location / {
root html;
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;
location = /50x.html {
root 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;
#}
}


# 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 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;
# }
#}

}
配置完后,执行reload命令重新加载配置文件。然后进行访问图片,http://127.0.0.1:8089/xxx.png
如果能访问,说明搭建成功。

----------------------------------------------------------------------------------
Linux下安装nginx,需要先安装Gcc编译器、PCRE库、zlib库、OpenSSL开发库。然后再安装nginx,
解压:tar -zxvf nginx-1.3.15.tar
编译安装命令:
./configure
make
make install

Linux下配置nginx图片服务器:
nginx version: nginx/0.6.35
nginx启动:/opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
nginx关闭:ps -au|grep nginx
然后kill -9 进程id 或 killall -9 nginx
nginx.conf配置文件内容如下:
user root;
worker_processes 1;
worker_rlimit_nofile 65535;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 12040;
}


http {
include mime.types;
default_type application/octet-stream;
#Proxy_cache_path /pic/image_cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g ;
#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 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 / {
root html;
index index.html index.htm;
#proxy_pass http://192.168.10.223:1234;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root 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;
#}
}


# 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 server
#
server {
listen 7788;
server_name localhost;
# ssl on;
# ssl_certificate /usr/local/nginx/conf/server.crt;
# ssl_certificate_key /usr/local/nginx/conf/server_nopwd.key;

charset utf-8;
#charset koi8-r;

location ~ (\.jsp)|(\.do) {
proxy_pass http://127.0.0.1:7001;
proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_max_temp_file_size 512m;
}
}

server {
listen 8089;
server_name localhost;

charset utf-8;

location ~ .*\.(gif|jpg|jpeg|png)$ {
#allow 127.0.0.1;
#deny all;


#expires 24h;
root /home/weblogic/pic/;
access_log /opt/nginx/logs/log_test.log;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;

proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 1024k;
proxy_buffers 40 1024k;
proxy_busy_buffers_size 1024k;
proxy_temp_file_write_size 1024k;
proxy_temp_path /home/weblogic/pic/;
#Proxy_cache_path /pic/;
if ( !-e $request_filename)
{
proxy_pass http://127.0.0.1:8089;
}

}
location / {
root html;
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;
location = /50x.html {
root html;
}

}

}


failed Permission denied 权限问题
修改nginx.conf文件中
user nobody
改成:user root

nginx recv() failed (104: Connection reset by peer) while reading response header from upstream
修改nginx.conf文件中:
if ( !-e $request_filename)
{
proxy_pass http://127.0.0.1:8089;
}
AI-PPT 一键生成 PPT:用户输入主题关键词,AI-PPT 可快速生成完整 PPT,涵盖标题、正文、段落结构等,还支持对话式生成,用户可在 AI 交互窗口边查看边修改。 文档导入转 PPT:支持导入 Word、Excel、PDF 等多种格式文档,自动解析文档结构,将其转换为结构清晰、排版规范的 PPT,有保持原文和智能优化两种模式。 AI-PPT 对话 实时问答:用户上传 PPT 或 PPTX 文件后,可针对演示内容进行提问,AI 实时提供解答,帮助用户快速理解内容。 多角度内容分析:对 PPT 内容进行多角度分析,提供全面视野,帮助用户更好地把握内容结构和重点。 多语言对话支持:支持多语言对话,打破语言障碍,方便不同语言背景的用户使用。 AI - 绘图 文生图:用户输入文字描述,即可生成符合语义的不同风格图像,如油画、水彩、中国画等,支持中英文双语输入。 图生图:用户上传图片并输入描述,AI - 绘图能够根据参考图和描述生成新的风格化图像,适用于需要特定风格或元素的创作需求。 图像编辑:提供如 AI 超清、AI 扩图、AI 无痕消除等功能,用户可以上传图片进行细节修改和优化,提升图片质量。 AI - 文稿 文案生成:能够根据用户需求生成多种类型的文章,如市场营销文案、技术文档、内部沟通内容等,提升文案质量和创作效率。 文章润色:对已有文章进行改善和优化,包括语言表达、逻辑连贯性、内容流畅度等方面,使文章更符合用户期望和风格。 文章续写:AI 技术理解文本语境,为用户提供新的想法、补充资料或更深层次的见解,帮助用户丰富文档内容。 AI - 医生 智能健康咨询:包括症状自查,用户输入不适症状,AI 结合病史等信息提供疾病可能性分析与初步建议;用药指导,支持查询药品适应症、禁忌症等,并预警潜在冲突;中医辨证,提供体质辨识与调理建议。 医学报告解读:用户上传体检报告
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值