This question is similar as this one QGIS Server not working (problem with fast CGI), but with more details:
I installed the latest QGIS from trunk on Linux (Ubuntu 11.04) in the non-default location '/usr/local/qgis/'. I installed apache2 from the repository.
Next,I followed the steps outlined in this post on Linfiniti's blog (http://linfiniti.com/2010/08/qgis-mapserver-a-wms-server-for-the-masses/), but probably I did not understand the part about telling apache about the library path for my CGI; where do I add the ScriptAlias code to?
I created a qgis project with two vector (shapefiles). Under WMS server tab of the project properties I checked 'service capabilities' and gave the title 'trial'. I copied the qgs project file to the /usr/lib/cgi-bin/VECEA directory.
Trying http://localhost/cgi-bin/VECEA/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities in the browser gets me the 'capability' xml file. It contains the user information, but there is no information on the data layers (the qgis project has two shapefile vector layers) and the bounding box is not defined (all set at 0), is that right (I did define an 'advertised extent' in the qgis project under the WMS tab)
In QGIS I can connect to the server. However, it just gives me one row with the name of the project (ID 0), whereas I would expect it to show the two vector layers that were part of the project. When adding the layer, it is empty.
Edit: and now it stopped working altogether. When trying the getCapabilities, I am getting a 500 Internal Server error. Looking in the apache2 error log I am finding the following:
[Tue Sep 27 20:53:03 2011] [error] [client 127.0.0.1] Premature end of script headers: qgis_mapserv.fcgi /usr/lib/cgi-bin/VECEA/qgis_mapserv.fcgi: error while loading shared libraries: libqgis_core.so.1.8.0: cannot open shared object file: No such file or directory
Edit: Got the 'getCapabilities' part to work again. In http://lists.osgeo.org/pipermail/qgis-user/2011-March/011549.html, it was suggested to add LD_LIBRARY_PATH to /etc/apache2/mods-> enabled/fcgi.conf, adding the line "DefaultInitEnv LD_LIBRARY_PATH /usr/local/qgis_git/lib". Only, I had to edit '/etc/apache2/mods-available/fcgid.conf'
Still stuck with no layers showing when connecting to the server in QGIS