Centos搭建Nginx图片缓存服务器
2017-12-05 14:46
507 查看
搭建Nginx图片缓存服务器
[root@localhost ~]# yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl*
[root@localhost ~]# useradd -M -u 40 -s /sbin/nologin nginx
[root@localhost ~]# tar zxvf ng
nginx-1.9.1.tar.gz nginx-upload-module-2.2.tar.gz ngx_cache_purge-2.3.tar.gz
[root@localhost ~]# tar zxvf nginx-1.9.1.tar.gz -C /usr/src/
[root@localhost ~]# tar zxvf nginx-upload-module-2.2.tar.gz -C /usr/src/
[root@localhost ~]# tar zxvf ngx_cache_purge-2.3.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nginx-1.9.1/
[root@localhost nginx-1.9.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/usr/src/ngx_cache_purge-2.3 --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module
--add-module=/usr/src/nginx-upload-module-2.2
[root@localhost nginx-1.9.1]# make -j4
[root@localhost nginx-1.9.1]# make install
[root@localhost nginx-1.9.1]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[root@localhost nginx-1.9.1]# nginx
查看配置文件:
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
[root@localhost ~]# yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl*
[root@localhost ~]# useradd -M -u 40 -s /sbin/nologin nginx
[root@localhost ~]# tar zxvf ng
nginx-1.9.1.tar.gz nginx-upload-module-2.2.tar.gz ngx_cache_purge-2.3.tar.gz
[root@localhost ~]# tar zxvf nginx-1.9.1.tar.gz -C /usr/src/
[root@localhost ~]# tar zxvf nginx-upload-module-2.2.tar.gz -C /usr/src/
[root@localhost ~]# tar zxvf ngx_cache_purge-2.3.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nginx-1.9.1/
[root@localhost nginx-1.9.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/usr/src/ngx_cache_purge-2.3 --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module
--add-module=/usr/src/nginx-upload-module-2.2
[root@localhost nginx-1.9.1]# make -j4
[root@localhost nginx-1.9.1]# make install
[root@localhost nginx-1.9.1]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[root@localhost nginx-1.9.1]# nginx
查看配置文件:
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
#user nobody; user nginx; worker_processes 4; #error_log logs/error.log; error_log logs/error.log crit; #error_log logs/error.log info; pid logs/nginx.pid; worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; charset utf-8; server_names_hash_bucket_size 128; client_header_buffer_size 2k; large_client_header_buffers 4 4k; client_max_body_size 8m; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 4k; fastcgi_buffers 8 4k; fastcgi_busy_buffers_size 8k; fastcgi_temp_file_write_size 8k; open_file_cache max=204800 inactive=20s; open_file_cache_min_uses 1; open_file_cache_valid 30s; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/webp image/jpeg image/gif image/png; gzip_vary on; client_body_buffer_size 512k; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; proxy_temp_path /data/proxy_temp_dir; #设置Web缓存区名称为cache_one,内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为5GB。 #proxy_cache_path和proxy_temp_path设置的目录需要在同一分区,因为它们之间是硬链接的关系。 proxy_cache_path /data/proxy_cache_dir levels=1:2 keys_zone=cache_one:300m inactive=1d max_size=5g; keepalive_timeout 60; client_header_timeout 10; client_body_timeout 10; reset_timedout_connection on; send_timeout 10; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '\status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; upstream webservers{ server 127.0.0.1:8100; } include /usr/local/qxg/nginx/conf.d/*.conf; }[root@localhost ~]# vim /usr/local/qxg/nginx/conf.d/image.conf
server { listen 80; server_name 192.168.40.2; index index.php index.html index.htm; root /data/imgerserver/; autoindex on; autoindex_localtime on; autoindex_exact_size off; access_log /data/nginx/logs/soft.log combined; error_log /data/nginx/logs/soft-error.log debug; location ~ .*\.(webp|gif|jpg|jpeg|png|bmp|swf|ico)?$ { expires 30d; proxy_cache cache_one; proxy_cache_valid 200 304 301 302 10d; proxy_cache_valid any 1d; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_cache_key $host$uri$is_args$args; proxy_pass http://123.56.86.137:8010; } location /nginx-status { stub_status on; access_log on; allow 127.0.0.1; allow 10.44.38.122; deny all; } location ~ .*\.(js|css)?$ { expires 24h; } } server { listen 8010; server_name 192.168.40.2; root /data/imgerserver/; # autoindex on; autoindex_localtime on; autoindex_exact_size off; access_log /data/nginx/logs/image-access.log combined; error_log /data/nginx/logs/image-error.log debug; location ~ .*\.(webp|gif|jpg|jpeg|png|bmp|swf|ico)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 24h; } #proxy_cache cache_one; }
相关文章推荐
- centos6.5 nginx-1.8.0和ftp搭建图片服务器
- Nginx服务器上搭建图片缓存服务的基本配置解析
- 阿里云CentOS 7 搭建图片服务器 (Nginx+Vsftpd)
- ubutun14.04通过Nginx搭建图片服务器
- Centos5.4+Nginx-0.8.50+UWSGI-0.9.6.2+Django-1.2.3搭建高性能WEB服务器
- 阿里云服务器ECS centos7.2搭建nginx环境以及负载均衡
- ubuntu16.04搭建FASTDFS图片服务器并配置nginx
- Nginx搭建图片服务器
- [CentOS 7] 安装nginx第一步先搭建nginx服务器环境
- nginx搭建简单图片服务器
- centos7 nginx图片 服务器可以访问ftp用户上传的图片资源的配置
- 在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境
- Linux中用Nginx和FTP搭建图片服务器
- 免费提供一台已搭建好的 nginx + FastDFS图片服务器(Centos6.4),并已测试上传功能
- ftp&nginx搭建图片服务器
- Linux:安装nginx,搭建图片服务器
- nginx搭建图片服务器
- 搭建Nginx图片服务器
- nginx和ftp搭建图片服务器
- Nginx搭建图片服务器(Windows)