最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

nginx和tomcat訪問圖片和靜態(tài)頁面的配置方法

 更新時(shí)間:2018年04月28日 10:52:22   作者:nsh_chinaboy  
這篇文章主要介紹了nginx和tomcat訪問圖片和靜態(tài)頁面的配置方法,需要的朋友可以參考下

生產(chǎn)環(huán)境下,有時(shí)候需要訪問圖片,正常需要應(yīng)用ftp、nginx等配套使用,但是有時(shí)候?yàn)榱撕喕?,可以用以下的兩種簡單的訪問,說實(shí)話,就是為了偷懶,但是效果是能有的,這就行了,所以今天做這個(gè)簡化版的方便大家應(yīng)急之用。

第一種方法:nginx配置下

1、創(chuàng)建文件路徑:

[root@localhost /]# mkdir /data/soft/ 
[root@localhost ~]# cd /data/soft/ 
[root@localhost soft]# mkdir html images 

 2、在images目錄下面放入圖片

[root@localhost soft]# cd images/ 
[root@localhost images]# ll 
總用量 80 
-rw-r--r--. 1 root root 9503 4月 25 17:06 thPZFULFJN.jpg 
-rw-r--r--. 1 root root 16083 4月 25 17:06 thR2C5VCMZ.jpg 
-rw-r--r--. 1 root root 12218 4月 25 17:06 thRG3YX53T.jpg 
-rw-r--r--. 1 root root 15048 4月 25 17:06 thSUF51VTR.jpg 
-rw-r--r--. 1 root root 21799 4月 25 17:06 thVWSLF8ZE.jpg 

3、在html目錄下面放入一個(gè)測試文件

[root@localhost html]# cat index.html 
this is test page !!!! 

 4、安裝nginx,并啟動(dòng)

選用yum還是編譯看自己喜好,我選擇編譯,自己制定安裝模塊

解壓pcre-8.34.tar.gz zlib-1.2.8.tar.gz openssl-1.0.1g.tar.gz三個(gè)包并安裝

tar -zxvf pcre-8.34.tar.gz 
cd pcre-8.34 
/configure && make && make install 
tar -zxvf zlib-1.2.8.tar.gz 
cd zlib-1.2.8 
/configure && make && make install 
tar -zxvf openssl-1.0.1g.tar.gz 
cd openssl-1.0.1g 
/config && make && make install 

安裝Nginx

tar -zxvf nginx-1.9.0.tar.gz 
cd nginx-1.9.0 
#./configure --prefix=/data/soft/nginx \ 
--user=www \ 
--group=www \ 
--with-mail \ 
--with-mail_ssl_module \ 
--with-http_ssl_module \ 
--with-http_flv_module \ 
--with-http_dav_module \ 
--with-http_sub_module \ 
--with-http_spdy_module \ 
--with-http_realip_module \ 
--with-http_addition_module \ 
--with-http_gzip_static_module \ 
--with-http_stub_status_module \ 
--with-pcre=/data/src/pcre-8.34 \ 
--with-zlib=/data/src/zlib-1.2.8 \ 
--with-openssl=/data/src/openssl-1.0.1g 

 編譯并安裝

make && make install 
groupadd www 
useradd -g www www 

 修改nginx配置文件

[root@localhost nginx]# vim conf/nginx.conf 
 server { 
  listen 80; 
  server_name localhost; 
  #charset koi8-r; 
  #access_log logs/host.access.log main; 
  location ~ .*\.(gif|jpg|jpeg|png)$ { 
   expires 24h; 
   root /data/soft/images/;#指定圖片存放路徑 
   access_log /data/soft/nginx/logs/images.log;#日志存放路徑 
   proxy_store on; 
   proxy_store_access user:rw group:rw all:rw; 
   proxy_temp_path /data/soft/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 40 320k; 
   proxy_busy_buffers_size 640k; 
   proxy_temp_file_write_size 640k; 
   if ( !-e $request_filename) 
   { 
     proxy_pass http://127.0.0.1;#默認(rèn)80端口 
   } 
  } 
   location / { 
   root /data//soft/html; #html訪問路徑 
   index index.html index2.htm; #html文件名稱 
   } 
  } 
   error_page 404 /404.html; 

5 、此時(shí)可以測試看看

先是html頁面

在看看圖片

顯然,nginx設(shè)置下靜態(tài)頁面和圖片是可以訪問成功的,下面開始tomcat訪問設(shè)置

第二種方法:tomcat

1、查看jdk版本

 java -version 
openjdk version "1.8.0_65" 
OpenJDK Runtime Environment (build 1.8.0_65-b17) 
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode) 

2、解壓tomcat并啟動(dòng)

tar -xvf apache-tomcat-8.5.30.tar.gz 
[root@localhost tomcat]# sh bin/startup.sh 

3、本地測試能不能訪問

4、 上面正常,那么把頁面文件夾放到wepapps下面去,注意,html文件夾里有inde.html頁面的。

[root@localhost soft]# cp -rp html/ /data/soft/tomcat/webapps/ 

測試訪問html頁面

繼續(xù)把圖片文件夾放到wepapps下面去,images下面是有圖片的。

[root@localhost images]# cp -rp /data/soft/images/ /data/soft/tomcat/webapps/ 

直接在瀏覽器上訪問如下

 總結(jié):這樣,簡單的圖片訪問和html頁面訪問就可以使用了,非常方便,這兩個(gè)方法非常適用內(nèi)網(wǎng)環(huán)境,對(duì)于運(yùn)維來說是個(gè)不錯(cuò)的選擇。

以上所述是小編給大家介紹的nginx和tomcat訪問圖片和靜態(tài)頁面的配置方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論

邵阳县| 高碑店市| 西和县| 黑水县| 梓潼县| 古交市| 日喀则市| 光泽县| 攀枝花市| 绵竹市| 湄潭县| 铜山县| 遂昌县| 遂昌县| 绥宁县| 洛扎县| 雅安市| 宿州市| 承德市| 大城县| 渭南市| 兰州市| 台安县| 珠海市| 交口县| 剑川县| 华安县| 灌阳县| 祁东县| 平泉县| 革吉县| 襄城县| 和林格尔县| 香格里拉县| 丹东市| 太原市| 临高县| 红安县| 霍邱县| 雷山县| 济源市|