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