2015-05-07 52 views
0

我在Ubuntu上有mapcache,mapserver(WMS),nginx。我的指令:Mapcache没有缓存WMS

http://mapserver.org/id/mapcache/install.html#cgi-fastcgi-specific-instructions 

Nginx的* .conf文件:

location ~ ^/maps/ofp_10000(?<path_info>/.*|$) { 
     set $url_prefix "/maps/ofp_10000"; 
     mapcache /mapcache/ofp.xml; 
     error_page 404 = @fastcgi_mapcache; 
    } 

    location @fastcgi_mapcache { 
     fastcgi_pass 127.0.0.1:9001; 
     fastcgi_index mapserv; 
     fastcgi_param QUERY_STRING map=/ofp_10000/vrt_all.map&$query_string; 
     fastcgi_param REQUEST_METHOD $request_method; 
     fastcgi_param CONTENT_TYPE $content_type; 
     fastcgi_param CONTENT_LENGTH $content_length; 
     fastcgi_param SERVER_NAME $server_name; 
     fastcgi_param SERVER_PORT $server_port; 
     fastcgi_param PATH_INFO  $path_info; 
     fastcgi_param SCRIPT_NAME "/maps/ofp_10000"; 
    } 

ofp.xml:

<mapcache> 
     <cache name="tmp1" type="disk" layout="template"> 
       <template>/tmp/mapcache/{tileset}#{grid}#{dim}/{z}/{x}/{y}.{ext}</template> 
     </cache> 

     <source name="vmap0" type="wms"> 
       <getmap> 
       <params> 
        <FORMAT>image/jpeg</FORMAT> 
        <LAYERS>vrt_all</LAYERS> 
       </params> 
      </getmap> 

      <http> 
      <url>http://host/maps/ofp_10000?</url> 
      </http> 
    </source> 

    <tileset name="vrt_all"> 
      <source>vmap0</source> 
      <cache>tmp1</cache> 
      <grid>WGS84</grid> 
      <grid>g</grid> 
      <format>JPEG</format> 
      <metatile>2 2</metatile> 
      <metabuffer>10</metabuffer> 
      <expires>10000</expires> 
      <auto_expire>86400</auto_expire> 
    </tileset> 

    <default_format>JPEG</default_format> 

    <service type="wms" enabled="true"> 
      <full_wms>assemble</full_wms> 
      <resample_mode>bilinear</resample_mode> 
     <format>JPEG</format> 
     <maxsize>4096</maxsize> 
    </service> 
    <service type="wmts" enabled="true"/> 
    <service type="tms" enabled="true"/> 
    <service type="kml" enabled="true"/> 
    <service type="gmaps" enabled="true"/> 
    <service type="ve" enabled="true"/> 
    <service type="mapguide" enabled="true"/> 
    <service type="demo" enabled="true"/> 

    <errors>report</errors> 
    <log_level>warn</log_level> 
    <lock_retry>10000</lock_retry> 
    <lock_dir>/tmp</lock_dir> 
    <auto_reload>false</auto_reload> 

    </mapcache> 

http://host/maps/ofp_10000/demo/wms 

我WMS工作正常,但不CAC hing -/tmp/mapcache是​​空的。

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

回答

0

工作,糟糕的指令,需要启动mapcache.fcgi和nginx的配置,如:

location ~ ^/mapserver/ofp_10000(?<path_info>/.*|$) { 
      fastcgi_pass 127.0.0.1:9001; 
      fastcgi_index mapserv; 
      fastcgi_param QUERY_STRING map=/ofp_10000/vrt_all.map&$query_string; 
      fastcgi_param REQUEST_METHOD $request_method; 
      fastcgi_param CONTENT_TYPE $content_type; 
      fastcgi_param CONTENT_LENGTH $content_length; 
      fastcgi_param SERVER_NAME $server_name; 
      fastcgi_param SERVER_PORT $server_port; 
      fastcgi_param PATH_INFO  $path_info; 
      fastcgi_param SCRIPT_NAME "/maps/ofp_10000"; 
    } 

    location ~ ^/maps/ofp_10000(?<path_info>/.*|$) { 
      set $url_prefix "/maps/ofp_10000"; 
      mapcache /usr/local/share/mapcache/ofp.xml; 
      error_page 404 = @fastcgi_mapcache; 
    } 

    location @fastcgi_mapcache { 
      fastcgi_pass 127.0.0.1:9002; 
      fastcgi_param QUERY_STRING $query_string; 
      fastcgi_param REQUEST_METHOD $request_method; 
      fastcgi_param CONTENT_TYPE $content_type; 
      fastcgi_param CONTENT_LENGTH $content_length; 
      fastcgi_param PATH_INFO  $path_info; 
    } 

和mapcache的init.d:

   #! /bin/sh 
       if [ "$NETWORKING" = "no" ] 
       then 
         exit 0 
       fi 
       PREFIX=/usr 
       NAME=mapcache 
       PID=/var/run/mapcache.pid 
       DAEMON=$PREFIX/bin/spawn-fcgi 
       DAEMON_OPTS=" -a 127.0.0.1 -p 9002 -F 4 -u www-data -U www-data -P $PID $PREFIX/local/bin/mapcache.fcgi" 
       MAPCACHE_CONFIG_FILE=/usr/local/share/mapcache/ofp.xml 
      start() { 
         export MAPCACHE_CONFIG_FILE=$MAPCACHE_CONFIG_FILE 
         echo -n $"Starting $NAME " 
         exec $DAEMON $DAEMON_OPTS >> /dev/null 
         daemon --pidfile $PID 
         RETVAL=$? 
          echo 
         [ $RETVAL -eq 0 ] 
      } 
      stop() { 
        echo -n $"Stopping $NAME " 
        killproc -p $PID 
         #make sure all mapservers are closed 
        pkill -f mapcache.fcgi 
        RETVAL=$? 
        echo 
        if [ $RETVAL -eq 0 ] ; then 
          rm -f $PID 
        fi 
      } 
      restart() { 
       stop 
       start 
      } 

      if [ -f /lib/lsb/init-functions ]; then 
       . /lib/lsb/init-functions 
      elif [ -f /etc/init.d/functions ]; then 
       . /etc/init.d/functions 
      fi 
      # See how we were called. 
      case "$1" in 
       start) 
        start 
        ;; 
       stop) 
        stop 
        ;; 
       status) 
        status lt-mapserv 
        RETVAL=$? 
        ;; 
       restart) 
        restart 
       ;; 
       *) 
        echo $"Usage: $0 {start|stop|status|restart}" 
         RETVAL=2 
         ;; 
      esac 
      exit $RETVAL 

和ofp.xml更改网址:

   <source name="vmap0" type="wms"> 
       <getmap> 
        <params> 
        <FORMAT>image/png</FORMAT> 
         <LAYERS>vrt_all</LAYERS> 
        <MAP>/ofp_10000/vrt_all.map</MAP> 
        </params> 
       </getmap> 

       <http> 
         <url>http://host/mapserver/ofp_10000?</url> 
       </http> 
       </source>