- 浏览: 1983 次
- 性别:
- 来自: 上海
最新评论
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;
}
下载完后,解压,并把它放到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;
}
- nginx-1.5.8.zip (1.2 MB)
- 下载次数: 0
相关推荐
nginx图片服务器配置和https配置
配置Nginx作为图片服务器,首先需要创建或修改`nginx.conf`文件。在该配置文件中,我们需要定义一个或多个服务器块(server block),每个服务器块代表一个虚拟主机。对于图片服务器,通常配置如下: ```nginx ...
Nginx 图片服务器搭建 本文将详细介绍 Nginx 图片服务器的搭建过程,包括安装 Nginx、安装 vsftpd、搭建 Nginx 图片服务器三个步骤。通过本文,读者可以了解到 Nginx 图片服务器的基本概念和搭建方法,并掌握相关的...
搭建图片服务器的业务场景分析: 在集群应用中,用户图片资源的分散管理会带来不便,导致数据同步变得复杂。因此,搭建图片服务器成为了解决这一问题的关键步骤。图片服务器不仅能集中存储和管理图片资源,还能通过...
根据给定文件信息,以下知识点将详细阐述如何在Windows环境下使用Nginx搭建图片服务器。 首先,搭建图片服务器涉及到的基本步骤是在Windows系统上下载并安装Nginx。在进行安装之前,访问Nginx官方网站下载适合...
在Java分布式项目中,涉及到客户端上传图片到FTP服务器并由Nginx提供HTTP服务进行图片下载,这是一个典型的文件传输和Web服务集成的场景。这里主要涉及三个关键知识点:Java FTP客户端编程、Nginx服务器配置以及Java...
FastDFS+Nginx搭建图片服务器。FastDFS是用c语言编写的一款开源的分布式文件系统。FastDFS为互联网量身定制,充分考虑了冗余备份、负载均衡、线性扩容等机制,并注重高可用、高性能等指标,使用FastDFS很容易搭建...
3. **HTTP服务器**:了解如何设置Nginx作为基本的HTTP服务器,处理静态资源如HTML、CSS、JavaScript和图片等。 4. **反向代理**:Nginx作为反向代理可以隐藏后端服务器,提高安全性并实现负载均衡。学习如何配置...
搭建一个图片服务器通常涉及到两部分:Nginx服务器和FTP服务器。Nginx作为一个高性能的HTTP和反向代理服务器,适合处理静态资源如图片,而FTP服务器则用于上传和管理这些图片。 一、Nginx作为图片访问服务 1. **...
Nginx官网下载Windows版本的Nginx: http://nginx.org/en/download.html 将下载的软件包进行解压: 注意: 解压包的路径不能包含中文字符,否则Nginx服务启动不了 启动Nginx服务: “Windows键+R键”打开运行,...
在构建分布式场景下的图片服务器时,使用`nginx`与`ftp`相结合是一个常见的解决方案。`nginx`以其高性能、高并发的特性,常被用作反向代理和负载均衡器,而`ftp`(File Transfer Protocol)则是一种标准的网络协议,...
5. **静态文件处理**:Nginx对于静态文件(如HTML、图片、CSS、JavaScript等)的处理非常高效,通常比PHP、Python等动态语言更快。 6. **缓存功能**:Nginx可以缓存经常访问的资源,减少对后端服务器的压力,提高...
【Nginx 简单图片服务器解决方案】 在IT行业中,构建高效且可扩展的图片服务器对于提升用户体验至关重要。特别是随着互联网应用的发展,图片服务的需求日益增长,如何处理大量图片的上传、存储和访问成为了一个重要...
- **静态资源处理**:对于HTML、图片、CSS和JavaScript等静态文件,Nginx能快速高效地进行处理和缓存。 - **SSL/TLS支持**:Nginx可以配置为使用HTTPS,提供安全的网络通信。 - **URL重写**:通过配置规则,可以对...
在构建Web服务时,Nginx因其高性能、轻量级和...总的来说,通过Nginx搭建图片服务器并实现静态资源缓存,可以显著提升用户访问速度,减轻后端服务器压力,同时提供了一种高效、可靠的解决方案来处理高并发的图片请求。