所有软件都是在windows环境下的
1.FTP服务器的配置:
2.Nginx的配置:
(1)nginx.conf文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
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" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root 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 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;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include vhost/*.conf;
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
(2)image.imooc.com.conf文件
server {
listen 80;
autoindex off;
server_name image.imooc.com;
access_log c:/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;'\].*" ){
return 404;
}
location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
deny all;
}
location / {
root C:\ftpfile\img;
add_header Access-Control-Allow-Origin *;
}
}
3.我直接访问C:\ftpfile\img\QQ截图20190114201007.png,是可以访问到的,如下图所示:
我直接访问127.0.0.1,出现nginx的欢迎界面,如下图所示:
我访问ftp://localhost/img/,也是完全没有问题的,如下图所示:
我访问http://image.imooc.com/QQ%E6%88%AA%E5%9B%BE20190114201007.png,也是没有问题的,如下图所示:
4.上面写了这么多,只是想证明我的FTP服务器和Nginx都是配置正常的,下面说说我的问题。
我刚看完8-7小节,上传文件到FTP服务器失败了。
首先是index.jsp页面:
我点击上图红框中的上传文件按钮,跳转到下图:
我在新标签页中打开上述链接,报404错误,如下图。
我查看我的FTP文件夹,没有上传过来,所以上图报了404错误。
我将上图红框中的代码注释掉,想查看文件是否上传到了Tomcat对应的文件夹下,发现是上传成功的,如下图所示:
所以我是在Tomcat上传到FTP这个过程中出现了问题,但是idea没有报任何错误信息。
完全不知道如何解决。
我搜索过问答区类似的问题:链接描述
上面这位哥们和我遇到的问题很相似,但是我不清楚他是怎么解决的。我也试了他里面说的把下图红框中的"img"换为"",没有效果。
上图蓝色方框内的remotePath,我不知道这个变量是做什么用的,还有后面的changeWorkingDirectory是在做什么?
提问不易,希望老师能认真解答。