In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "Nginx how to cooperate with php to generate real-time thumbnail function". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn together "Nginx how to cooperate with php to generate real-time thumbnail function"!
nginx configuration:
The copy code is as follows:
#Suppose there is a file on the server: abc.jpg, which can be accessed through http://filefs.domain.com/file/abc.jpg. Its #is general, we also saved the "/file/abc.jpg" part of the content in the database.
#Now, we want to implement this thumbnail automatically generated by the server via http://filefs.domain.com/file/abc.jpg.w320.jpg (w320, 320px width). and return the image data.
#The following two conditions must be met:
# 1. If abc.jpg.w320.jpg exists, do not regenerate the picture
# 2. If it does not exist, return image data and save image file to server in the same request.
server {
listen 80;
server_name filefs.domain.com;
root /var/www/http/filefs.domain.com;
location / {
index index.html index.htm;
}
location ~ \. (png|jpg|jpeg|gif)$ {
#If the file does not exist, rewrite to the script file autoimg.php that generated the image
if (!- f $request_filename) {
rewrite ^/.*$ /autoimg.php;
expires max;
}
#Set expiration time if file exists, close access log
if ( -f $request_filename ) {
expires max;
access_log off;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ autoimg.php$ {#security considerations, file server, only the scope of this script file submitted to php processing
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param script_filename /var/www/http/filefs.domain.com$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}
php generates image file code:
The copy code is as follows:
Effect drawing:
Thank you for reading, the above is the content of "Nginx how to cooperate with php to generate real-time thumbnail function", after learning this article, I believe everyone has a deeper understanding of how Nginx cooperates with php to generate real-time thumbnail function. The specific use situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.