Hi Chris,

On Thu, Oct 10, 2013 at 4:14 PM, Chris Nicholas <chrisgnicho...@att.net>wrote:

> hi - wondering if anyone has actually gotten the 2.1 qgis_server stuff to
> work on MAC/OSX ...
>
> I've gotten it to work on Ubuntu like a champ, and oh-so-close on OSX ...
>
> I followed all the directions at:
> http://hub.qgis.org/projects/quantum-gis/wiki/QGIS_Server_Tutorial
>
> nothing worked at first;  I tried to to unravel things using dtrace(1) to
> see what it was looking for, and for some reason, either hard-coded or by
> defaults, it looks for a lot of stuff  in "/Users/larrys/ ..."
>
> so, I put in a symlink from
> /Users/larrys/QGIS/nightly/QGIS_Apps/QGIS_2.1-dev.app ->
> /Applications/QGIS_2.1-dev.app , and since it was apparently built in debug
> mode, the QGIS_LOG_FILE shows it actually rendering things to /private .
>

This is an oversight on my part with regards to a hard-coded path
(CMAKE_INSTALL_PREFIX, saved in qgisconf.h) established during the build
process. This is then referenced in qgis_map_serv.cpp and used if the
environment variable QGIS_PREFIX_PATH is not set [0].

For the nightly builds, in qgisconf.h, it is:
#define CMAKE_INSTALL_PREFIX
"/Users/larrys/QGIS/nightly/QGIS_Apps/QGIS_2.1-dev.app/Contents/MacOS"

since I (obviously) do not install the nightly to /Applications. Ideally,
Mac apps should be able to move about the filesystem and still function.
This is the only hard-coded path remaining, that I know of. So, the fix is
to set QGIS_PREFIX_PATH *before* qgis_mapserv.fcgi is spawned at Apache
launch. To do this I adjusted FastCgiConfig:

<IfModule mod_fastcgi.c>
  SetEnv QGIS_LOG_FILE /test-projects/qgis_wms_server.log
  FastCgiConfig -appConnTimeout 60 -idle-timeout 60 \
  -init-start-delay 1 -startDelay 5 -minProcesses 2 -maxClassProcesses 20 \
  -initial-env
QGIS_PREFIX_PATH=/Users/larrys/Applications/QGIS_2.1-dev.app/Contents/MacOS
\
  -initial-env
DYLD_FRAMEWORK_PATH=/Users/larrys/Applications/QGIS_2.1-dev.app/Contents/Frameworks
  ... more config ...
</IfModule>

Couple of things to note about this config:

* Notice QGIS_LOG_FILE env var is set at the Apache level, not for, or
passed to, the FCGI process, where (for some reason) it doesn't work. QGIS
has to be a debug variant build for output to file.

* /Users/larrys/Applications/QGIS_2.1-dev.app is where my download of the
nightly resides - denoted even though the qgis_mapserv.fcgi binary is
inside it. I now know of some Mac-specific C++ code to find the absolute
path to a launched binary (from inside itself) and can probably nix the
need for setting QGIS_PREFIX_PATH in the future.

* DYLD_FRAMEWORK_PATH is set because I have several versions/installs of Qt
on my Mac. When dynamically loading Qt frameworks, you will often see
warnings or errors about multiple copies being found and maybe get a crash.
Use DYLD_FRAMEWORK_PATH to append the app's embedded Qt frameworks' path.
These errors can also occur when the PyQt4 modules used by QGIS and QGIS
itself differ in found Qt frameworks as well. ANY Qt framework in a
standard location, beyond that found in the app, will cause the issue.

* DYLD_FRAMEWORK_PATH is still necessary if you are using the
qgis_mapserv.fcgi binary directly from the build directory of a locally
built QGIS source, and you have multiple Qt installs, as noted above.

These fixes should not be needed with a standard Kyngchaos.com QGIS.app
install into /Applications, unless maybe you move the .app bundle, or have
extra Qt installs.

Also of note, you should not move the qgis_mapserv.fcgi binary out of the
QGIS.app bundle, as it links to many resources/libs from that location. You
can set its directory up in Apache, a la the Server Tutorial [1], or
symlink it to a fcgi-bin and set 'Options FollowSymLinks' for the fcgi-bin
directory. However, you *can* relocate/copy the qgis_mapserv.fcgi binary
from the <build>/output/bin directory, as it is not bundle-specific, just
be sure to adjust the env vars to non-bundle resources accordingly, if
necessary.

Finally, after getting Server to work from the relocated nightly bundle, I
noticed there seems to be a rendering issue with latest master, where
layers would randomly not show up. It is unrelated to this issue because it
happens on other installs as well.

Please let me know if your test results differ. I will be adding these
notes to the nightly download site, its README, and probably the Server
tutorial page.

[0]
https://github.com/qgis/QGIS/blob/master/src/mapserver/qgis_map_serv.cpp#L163
[1] http://hub.qgis.org/projects/quantum-gis/wiki/QGIS_Server_Tutorial

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota


> rc/core/qgsmaprenderer.cpp: 625: (render) Done rendering map layers
> rc/core/qgsvectorlayer.cpp: 328: (drawLabels) Starting draw of labels:
> world_shapes20130924190607981
> rc/core/qgsmaprenderer.cpp: 692: (render) Rendering completed in
> (seconds): 0.021
> rc/mapserver/qgswmsserver.cpp: 689: (getMap) clearing filters
> rc/mapserver/qgis_map_serv.cpp: 554: (main) Sending GetMap response
> rc/mapserver/qgshttprequesthandler.cpp: 96: (sendGetMapResponse) Sending
> getmap response...
> rc/mapserver/qgshttprequesthandler.cpp: 45: (sendHttpResponse) Checking
> byte array is ok to send...
> rc/mapserver/qgis_map_serv.cpp: 556: (main) Response sent
>
> But for some reason, at the very end, I get a 500 error ...  :-(
>
> comment/suggestions/RTFMs welcomed!
>
> thanks -
> Chris
>
>
>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to