Nginx Build Access Image Server

Source: Internet
Author: User

The test environment in this paper is under Ubuntu16.04

1. First in the terminal input

sudo apt-get install Nginx

2. Test after installation, enter the following command, or open the browser input http://localhost

Curl localhost

Display Welcome screen indicates successful installation

3. Create a new images folder under/home/lemon/documents, and download a few photos, named 1.jpg,2.jpg ...

4. Go to the/etc/nginx/site-enabled/directory, make a backup of the default file, and enter the following command

sudo vim default

Modify to the following content

server {Listen 80;        server_name localhost; CharSet utf-8;location ~. *\.      (gif|jpg|jpeg|png) ${expires 24h; root/home/lemon/documents/images;#Specify picture storage pathProxy_store on;      Proxy_store_access USER:RW GROUP:RW ALL:RW; Proxy_temp_path/home/lemon/documents/images;#图片访问路径Proxy_redirect off;      Proxy_set_header Host 127.0.0.1;      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 320k; Proxy_busy_buffers_size 640k;        if (!-e $request _filename) {Proxy_pass http://127.0.0.1; #默认80端口}}root/var/www/html;        # ADD index.php to the list if is using PHP index index.html index.htm index.nginx-debian.html;        server_name _; Location/{# First attempt-serve request as file, then # as directory, then fall back T                o Displaying a 404.        Try_files $uri $uri/= 404; }  }

5. Enter the following command to verify that the code in the script is correct

sudo nginx-t

Success appears to be successful

6. Enter the following instructions to reload

sudo nginx-s reload

7. Enter localhost/1.jpg in the browser to see the picture

Nginx Build Access Image Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.