installing Apache, QGIS Server, and Lizweb Map on Windows OS - this time using Apache 2.4.33, QGIS Server LTR 2.18.21 and Lizmap Web Client 3.1.12. I just updated my Windows Server 2016 and needed to redo my GIS server. This post includes screenshots so hopefully it will be more helpful with details. This shows the process on my Windows 10 Pro laptop but should be the same for a Windows Server 2016 (which I've done at my work). If this helps you or if you find any errors or have any suggestions, let me know in the comments section. For my test on my Windows 10 Pro laptop, I have everything on the same machine. But on the Windows Server 2016 machine, I have QGIS Desktop with Lizmap Web Plugin on a different machine. For my installation I put Apache and Lizmap side-by-side inside a C:/webserver directory. You can however, put your installations inside of Apache root directory (e.g. C:/Apache24/Lizmap) or inside Apache htdocs directory (e.g. C:/Apache24/htdocs/lizmap). If installation of Lizmap and Apache are side by side or Lizmap is inside Apache root directory then you need to properly configure the virtual hosts. Software Used/Requirements:
- Lizmap and QGIS Server must be on same machine
- QGIS Server LTR 2.18.21 (installed via OSGeo4W x64)
- QGIS Desktop (installed via OSGeo4W x64)
- Lizmap Web Plugin (installed via QGIS Desktop plugin manager)
- Lizmap Web Client 3.1.12
- Apache 2.4.33
- mod fcgid
- C++ Redistributable VS 2015
- PHP 7.2.7
- Apache 2.4.33 Win64: httpd-2.4.33-win64-VC15.zip
- mod_fcgid: mod_fcgid-2.3.9-win64-VC15.zip
- Visual C Redistributable Package: vc_redist_x64
- Uncomment the ServerName line - that is remove the # character
- Change from ServerName www.example.com:80 to ServerName localhost:80
c. Optional - Find where it says “Listen 80” to and change the port number if not using the default 80 (e.g. Listen 90). You need to use a port that is not already in used by another service.
d. Find where it says “DirectoryIndex index.html” and add index.php (e.g. DirectoryIndex index.html index.php)
e. Save your changes. You can keep the configuration file open
6. Check to see if Apache will start. To quickly check to see Apache configurations work and to see if Apache starts up correctly you can run the httpd.exe as a console application. You can use the command window (CMD) to run the httpd.exe or go into the directory where httpd.exe is located and run as admin.
a. Go to \Apache24\bin folder (e.g. C:\webserver\Apache24\bin) and right click on httpd.exe and run as administrator
b. If you get a pop up, allow the app to run - you should then get a console window (black window) that pops up - keep this window open (if you close it, Apache will stop)
c. Then in a web browser type in http://localhost or http:localhost:port and you should see a webpage with "It Works!" This means Apache is installed correctly
d. To stop Apache you can just close the console window (black window above)
7. Run Apache as a Windows Service rather than as a console application. Running as a service should be preferred because this lets Apache end any current operations and clean up gracefully. See https://httpd.apache.org/docs/2.4/platform/windows.html#winsvc for more info.
a. Optional - Append Apache to your Windows System Path so you can directly access Apache by just typing httpd.exe instead of the full pathname to it.
b. Start Apache as Windows Service:
- Go to the Command Prompt (CMD) and run as administrator
- Install Apache as a service: httpd.exe -k install
- Open your Windows Services Manager: you should see Apache as a listed service.
- Select Apache service and start it
- Then in web browser, try http://localhost or http://localhost:port and you should get "It Works!"
- Stop the Apache service for now as you'll do more configuration - you can keep the services window open
8. Edit Apache configuration (httpd.conf) to enable needed modules. Open Apache24\conf\httpd.conf (e.g. C:\webserver\Apache24\conf\httpd.conf) and edit it.
a. Remove the # character in front of each of the following module to enable it.
Note: If you don't see the module already in the file then you need to type it in - for example I had to insert mod_fcgid.so module
- LoadModule actions_module modules/mod_actions.so
- LoadModule deflate_module modules/mod_deflate.so
- LoadModule expires_module modules/mod_expires.so
- LoadModule ext_filter_module modules/mod_ext_filter.so
- LoadModule fcgid_module modules/mod_fcgid.so
- LoadModule headers_module modules/mod_headers.so
- LoadModule ident_module modules/mod_ident.so
- LoadModule rewrite_module modules/mod_rewrite.so
- LoadModule ssl_module modules/mod_ssl.so
- LoadModule cache_module modules/mod_cache.so
- LoadModule cache_disk_module modules/mod_cache_disk.so
- LoadModule proxy_module modules/mod_proxy.so
- LoadModule proxy_connect_module modules/mod_proxy_connect.so
- LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
- LoadModule proxy_http_module modules/mod_proxy_http.so
4. Open php.ini file (e.g. C:\webserver\php72\php.ini) in a text editor and make the following changes
a. Find where it says ;extension_dir = "ext" and remove the ; character and replace "ext" with the path to your php ext folder (e.g. "C:/webserver/php72/ext")
b. Enable the following php modules by removing the ; character
- extension=php_curl
- extension=php_fileinfo.
- extension=php_gd2
- extension=php_mbstring
- extension=php_pdo_pgsql
- extension=php_pdo_sqlite.
- extension=php_pgsql
- extension=php_sqlite3
c. Find where it says "upload_max filesize" and change it to 15M
d. Find where it says "post_max_size" and change it to 15M
e. Save your configuration changes to the php.ini file
5. Add PHP to your Windows System Path (e.g. add C:\webserver\php72 to your Windows system path - same as in Part 2, step 7)
6. Open Command Prompt and check to see if PHP is correctly declared in system path: run CMD as admin, then type in php -m. You should get a list of php modules back.
Part 4: Configure Apache for Using PHP
1. Open a new file in a text editor then put in the following code - save the file as php72.conf in \Apache24\conf\extra folder (e.g. C:\webserver\Apache24\conf\extra\php72.conf)
FcgidInitialEnv PHPRC "C:\\webserver\\php72"
<FilesMatch \\.php$>
AddHandler fcgid-script .php
FcgidWrapper "C:/webserver/php72/php-cgi.exe" .php
</FilesMatch>
2. Open and edit Apache httpd.conf file (e.g. C:\webserver\Apache24\conf\httpd.conf)
- Uncomment or remove the # character: Include conf/extra/httpd-vhosts.conf
- Save changes to file
3. Open and edit httpd-vhosts.conf file (e.g. C:\webserver\Apache\Conf\extra\httpd-vhosts.conf ) for use with Lizmap
a. Delete the two examples that are included in the file and insert the following code. Note: don't forget to change the port if you're using something other then default 80
<VirtualHost *:80>
Include conf/extra/php72.conf
ServerName localhost
DocumentRoot "C:/webserver/lizmap/"
<Directory "C:/webserver/lizmap">
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Require all granted
</Directory>
CustomLog "logs/lizmap-access.log" common
ErrorLog "logs/lizmap-error.log"
</VirtualHost>
4. Create a lizmap folder inside the main webserver directory (e.g. C:\webserver\lizmap)
5. Create a text file with following code and save it as index.php inside the lizmap folder (e.g. C:\webserver\lizmap\index.php)
<?php
phpinfo();
?>
6. Restart Apache service
7. Check to see if PHP works. In a web browser, type in http://localhost/index.php (or http://localhost:port/index.php if not using default 80)
Part 5: Install and Configure QGIS Server
I installed QGIS Server using OSGeo4W installer x64 version – download on QGIS site or on OSGeo4W site. Lizmap Web Client doesn’t work properly with the QGIS Server 3.0 , so you must use the LTR 2.18.21. I did try with QGIS Server 3.x but it didn’t work. Note: I have both QGIS dekstop 3.2 and 2.18.21 and QGIS Server 2.18.21 on my machine and they both work fine so far.
If you don't already have QGIS desktop then you have the option to install it via Express install using the OSGeo4W installer (this is easier) or through the advance option.
1. Run the OSGeo4W installer: Select Advance Setup
a. Install from Internet
b. Keep Root Directory default and install for all users
c. Keep default Local Package Directory and Start Menu Name
d. Select these Packages:
- Commandline_Utilities: GDAL
- Desktop: QGIS LTR 2.18.21 full (if needed)
- Libs: fcgi
- Optional Lib: filegdb (only if you want to be able to use ESRI file gdb)
- Web: QGIS Server LTR 2.18.21
2. After installation completes, check in C:\OSGeo4W64\apps\qgis-ltr\bin folder to make sure these files are in there.
- qgis_mapserv.fcgi.exe
- qgis_server.dll
- wms_metadata.xml
Part 6: Install and Configure Lizmap Web Client
1. Download Lizmap Web Client – I used lizmap-web-client-3.1.12.zip.
2. Create in C:\webserver\lizmap directory, 2 new folders for your production and preproduction work. Make sure you have write access to these folders
- C:\webserver\lizmap\prod
- C:\webserver\lizmap\preprod
- C:\webserver\cache\prod
- C:\webserver\cache\preprod
8. Keep your command prompt window open
9. Open Lizmap's localconfig.ini.php file (e.g. C:\webserver\lizmap\prod\lizmap-web-client-3.1.12\lizmap\var\config\localconfig.ini.php) in a text editor and include the following code if you want to install the Lizmap demo websites – make sure you have admin rights to modify and save this file (e.g. run notepad++ as Administrator then modify and save changes).
[modules]
lizmap.installparam=demo
10. Back in the Command Prompt, launch Lizmap installation by typing in the following lines. After installation completes, close the command prompt window.
cd C:\webserver\lizmap\prod\lizmap-web-client-3.1.12\
php lizmap/install/installer.php
11. In web browser, type in http://localhost/index.php - you should see the Lizmap demo page
The Lizmap Web Client Dashboard
1. In the Lizmap home page (see above image), click the Connect button in the top right or go to http://localhost/admin.php to access the login page:
- Login with default username = admin, password = admin
3. Lizmap Configuration menu: Modify the Lizmap generic configuration - input as follows and then save new configuration.
- QGIS server version: >= 2.18
- WMS Server URL: http://127.0.0.1/qgis/qgis_mapserv.fcgi.exe
- Cache root directory: C:/webserver/cache/prod/
4. Click over to PROJECTS (top right corner) and you can view the metadata of the demo or load the demo map
Here is the Montpellier Demo web app.
Part 7: SVG and QGIS Bug
I’m not sure if this still hold true or not, but not a bad idea to do it. In Apache you need to Add a vhost to publish SVG and images files via HTTP this will avoid the bug in QGIS Server under Windows which cannot display SVG icon when you have a relative path.
1. Create a folder to contain the svg files (e.g. C:/webserver/data/document/svg)
2. Then modify C:/webserver/Apache24/conf/extra/httpd-vhosts.conf . Add the codes before the CustomLog portion.
Alias /document/ "C:/webserver/data/document/"
<Directory "C:/webserver/data/document/">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
3. Save and restart Apache service.
4. Check if you can add svg file in the folder C:/webserver/webapp/document/svg then access it via http://localhost/document/svg/my_icon.svg and use it as the SVG path in the style properties of a vector layer.
That's it for this post. I hope this helps you get your GIS server running. See Lizmap Documentation for more info on configuration and user/publisher manual. I will do a part 2 soon - on how to use the Lizmap plugin for QGIS to prepare and publish a QGIS project. If you've read this entire post then thank you for reading and I hope it worked out for you. Until next time.
]]>
Chào anh, anh có thể tư vấn cho em liên quan đến gis chút được không ạ. Cụ thể là em đang cần xây 1 map server nhỏ, dạng local, có input là dữ liệu map của em (file mapbase và các file kml), mong muốn output dạng WMTS hoặc WMS để các máy web client có thể sử dụng output hiển thị lên bản đồ từ dữ liệu của em. Trong đó thỉnh thoảng em cần chỉnh sửa, thêm bớt các point, line hoặc polygon trên bản đồ, cũng như cần thay đổi bản đồ nền. Nếu như vậy thì em nên dùng những phần mềm nào ạ. EM có tìm hiểu qua (geoserver + openlayer + postgis) và Qgis server, có vẻ hợp nhưng cài xong không làm sao cấu hình được ạ. Anh có thể tư vấn em phần mềm nào phù hợp hoặc chỉ giúp em với ạ. Thanks