搭建nginx图片服务器

(1)将图片存储于/home/data/images目录;
(2)配置nginx.conf


user  nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  10000;
}


http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
	
	autoindex on;
}

(3)配置default.conf

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/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   /usr/share/nginx/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;
    #}
	
	location /status {
		stub_status on;
	}
	
	location /images {
		root /home/data;
	}
}

(4)测试

相关推荐

  1. Nginx服务案例

    2024-01-27 21:06:01       15 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-27 21:06:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-27 21:06:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-27 21:06:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-27 21:06:01       20 阅读

热门阅读

  1. 51单片机编译没有报错,但是下载后程序不更新

    2024-01-27 21:06:01       34 阅读
  2. 向量数据库知识积累

    2024-01-27 21:06:01       31 阅读
  3. 使用docker 搭建palworld 服务器

    2024-01-27 21:06:01       35 阅读
  4. Excel VBA ——从MySQL数据库中导出一个报表-笔记

    2024-01-27 21:06:01       37 阅读
  5. Android 13.0 SystemUI下拉状态栏禁止QuickQSPanel展开

    2024-01-27 21:06:01       37 阅读
  6. 前端常用的时间格式处理

    2024-01-27 21:06:01       27 阅读
  7. 简单计算器

    2024-01-27 21:06:01       34 阅读
  8. 【算法专题】动态规划之子序列问题

    2024-01-27 21:06:01       32 阅读
  9. 《微信小程序开发从入门到实战》学习九十四

    2024-01-27 21:06:01       40 阅读