Note: This article refers to the csdn:java_direction "Nginx and FTP to build a picture server " article. In practice, the article is still flawed in centos7.
A: The prerequisite: is the successful installation of the FTP server and Nginx server, if not installed please refer to the CentOS7 building an FTP server " and" centos7_ Linux:nginx Installation manual "
Second: Open the Ftpuser user's home directory to other users access rights:
1 [[email protected] home]# chmod-r 777 ftpuser/ 2
Three: Set the access path in the Nginx configuration file
1: Enter the directory of the configuration file:
1 cd/usr/local/nginx/conf/
2;nginx Default configuration file Nginx.config
1 #user Nobody; 2Worker_processes 1;3 4 #error_log Logs/error.log; 5 #error_log Logs/error.log Notice; 6 #error_log Logs/error.log Info; 7 8 #pid Logs/nginx.pid; 9 Ten OneEvents { AWorker_connections 1024; -} - the -HTTP { -Include MIME.Types; -Default_type Application/octet-stream; + - #log_format main ' $remote _addr-$remote _user [$time _local] "$request" ' + # ' $status $body _bytes_sent ' $http _referer ' A # ' "$http _user_agent" "$http _x_forwarded_for" '; at - #access_log Logs/access.log Main; - -Sendfile on; - #tcp_nopush on; - in #keepalive_timeout 0; -Keepalive_timeout 65; to + #gzip on; - theserver { *Listen 80; $server_name localhost;Panax Notoginseng - #charset Koi8-r; the + #access_log Logs/host.access.log Main; A theLocation/{ +root HTML; - Index Index. htmlIndex. htm; $} $ - #error_page 404/404.html; - the # REDIRECT Server error pages to the static page/50x.html - # WuyiError_page 502 503 504/50x.html; theLocation =/50x.html { -root HTML; Wu} - About # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 $ # - #location ~ \.php$ { - # Proxy_pass http://127.0.0.1; - #} A + # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 the # - #location ~ \.php$ { $ # root HTML; the # Fastcgi_pass 127.0.0.1:9000; the # Fastcgi_index index.php; the # Fastcgi_param Script_filename/scripts$fastcgi_script_name; the # include Fastcgi_params; - #} in the # Deny access to. htaccess files, if Apache ' s document Root the # concurs with Nginx ' s one About # the #location ~/\.ht { the # deny All; the #} +} - the Bayi # Another virtual host using mix of ip-, name-, and port-based configuration the # the #server { - # Listen 8000; - # Listen somename:8080; the # server_name somename alias Another.alias; the the # location/{ the # root HTML; - # index index.html index.htm; the # } the #} the 94 the # HTTPS Server the # the #server {98 # listen 443 SSL; About # server_name localhost; - 101 # ssl_certificate Cert.pem; 102 # Ssl_certificate_key Cert.key; 103 104 # Ssl_session_cache shared:ssl:1m; the # ssl_session_timeout 5m; 106 107 # ssl_ciphers high:!anull:! MD5; 108 # ssl_prefer_server_ciphers on; 109 the # location/{111 # root HTML; the # index index.html index.htm; 113 # } the #} the the}
Three: Configure Picture server
Method One, in configuration file server{} location/{} Modify the configuration:
1 #默认请求 2 location/{ 3 root /home/ftpuser/www; #定义服务器的默认网站根目录位置 4index index . htm; #定义首页索引文件的名称 5 }
Where:/home/ftpuser/www; www directory under the root directory of the Ftpuser for creating FTP service accounts
Note: If you are following the reference I provided CentOS7 building an FTP server " and" centos7_ Linux:nginx Installation manual "After the operation of the procedure, after uploading the image to the server with FTP, restart the nginx server;
You should be able to see the picture information directly in the browser.
CENTOS7 nginx Image Server can access the configuration of image resources uploaded by FTP users