This repository has been archived by the owner on Mar 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.md~
executable file
·256 lines (183 loc) · 6.21 KB
/
README.md~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Floodject
This is a project created by Ioannis Angelidis, David Nagy and Emil Møller Rasmussen.
## PyPWS
### Installation
Installing PyWPS can be a nightmare if trying to follow the instructions from the official documentation, as they are old and your server setup might differ. They are found in the links below:
```
http://pywps.wald.intevation.org/documentation/installation.html
```
```
http://pywps.wald.intevation.org/documentation/course/
```
Luckily, one of the developers (Luis de Sousa) working on PyWPS gave detailed instructions on how to install PyWPS on Ubuntu 14.04 in the following stackexchange thread:
```
http://gis.stackexchange.com/questions/83743/how-to-install-pywps-on-ubuntu
```
The instructions from there are partly used below, but changed to fit with the individual server setup:
#### Actual installation
Install dependencies, clone the project from GitHub and install it:
```
sudo apt-get install apache2 python-setuptools python-magic python-lxml git-core wget
git clone https://github.com/geopython/PyWPS.git
cd ./PyWPS
sudo python setup.py install
```
#### Create folders for PyWPS assets
For convenience, in this example all PyWPS assets are stored in /var/www/html, a typical setup for a development environment. In a server setup it might be wiser to store processes in /srv and logs in /var/log.
```
sudo mkdir /var/www/html/pywps
sudo mkdir /var/www/html/wpsoutputs
sudo cp -R pywps/processes /var/www/html/pywps
```
Create log and configuration files:
```
sudo touch /var/www/html/pywps/pywps.log
sudo cp pywps/default.cfg /var/www/html/pywps/pywps.cfg
sudo pico /var/www/html/pywps/pywps.cfg
```
In the configuration file only the Server environment needs to be tweaked, in order to match the asset locations created before. The set up of the GRASS and MapServer environments are left for a later date.
```
[server]
maxoperations=30
maxinputparamlength=1024
maxfilesize=500mb
tempPath=/tmp
processesPath=/var/www/html/pywps/processes
outputUrl=http://localhost/wpsoutputs
outputPath=/var/www/html/wpsoutputs
debug=true # deprecated since 3.2, use logLevel instead
logFile=/var/www/pywps/pywps.log
```
Pass ownership to the www-data user (again, in a server setup you might want to be more conservative):
```
sudo chown -R www-data:www-data /var/www/html/pywps /var/www/html/wpsoutputs
```
#### Configure the web service
Copy the PyWPS CGI to /usr/lib/cgi-bin:
```
sudo cp webservices/cgi/pywps.cgi /usr/lib/cgi-bin
whereis wps.py
```
Copy the path of wps.py to the clipboard.
```
sudo pico /usr/lib/cgi-bin/pywps.cgi
```
Modify pywps.cgi to match the present setup:
```
export PYWPS_CFG=/var/www/html/pywps/pywps.cfg
export PYWPS_PROCESSES=/var/www/html/pywps/processes/
/usr/local/bin/wps.py $1
```
Give it a try:
```
cd /usr/lib/cgi-bin
sudo sh pywps.cgi "request=GetCapabilities&service=WPS"
```
Make sure Apache is configured to run CGI scripts; the CGI module might need to be explicitly enabled:
```
sudo a2enmod cgid
```
Edit the default site configuration
```
sudo pico /etc/apache2/sites-available/000-default.conf
```
Add the following to the file:
```
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
```
Restart Apache:
```
sudo service apache2 restart
```
# Various URL strings for accessing the WPS service
#### Get capabilities
http://52.17.144.192/cgi-bin/pywps.cgi?service=WPS&version=1.0.0&request=getcapabilities
#### Execute a function
http://52.17.144.192/cgi-bin/pywps.cgi?request=execute&service=WPS&version=1.0.0&identifier=flooding&datainputs=[rasterin%3Dhttp%3A%2F%2F52.16.38.28%2FNEWTIF.tif%3Bvectorin%3Dhttp%3A%2F%2F52.16.38.28%2Ftest.geojson]
#### Describe process
http://52.17.144.192/cgi-bin/pywps.cgi?service=WPS&version=1.0.0&request=DescribeProcess&Identifier=flooding
# Installations
### Installation structure of PyWPS
To give a better overview of where the files on the server have been installed, a file-tree of the location of all important files is provided below:
```
/
├── /var/
| └── /www/
| └── /html/
| └──/pywps/
| ├── pywps.cfg
| ├── pywps.log
| ├── /wpsoutputs/
| └── /processes/
| └── __init__.py
| └── process1.py
├── /lib/
| └── /cgi-bin/
| └── pywps.cgi
|
└── /etc/
└── /apache2/
└── /sites-available/
└── 000-default.conf
```
### GRASS installation on server
```
~
├── .grass6
| └── rc
└── grassdata
└── <LOCATION>
└── <MAPSET>
```
### File structure of the webserver
```
/
└── /var/
└── /www/
└── /html/
└── /FlaskApp/
├── flaskapp.wsgi
└── /FlaskApp/
├── /templates/
├── /static/
├── /images
└── __init__.py
```
### Debugging
When wanting to debug there are two important file locations, the first one is the pywps.log that we created above, the second one is the general server (apache) error log. These are found in these locations
```
/
└── /var/
├── /www/
| └── /html/
| └── /pywps/
| └── pywps.log
|
└── /log/
└── /apache2/
└── error.log
```
### CGI-BIN
CGI wrapper
```
#!/bin/sh
# Author: Jachym Cepicky
# Purpose: CGI script for wrapping PyWPS script
# Licence: GNU/GPL
# Usage: Put this script to your web server cgi-bin directory, e.g.
# /usr/lib/cgi-bin/ and make it executable (chmod 755 pywps.cgi)
# NOTE: tested on linux/apache
export PYWPS_CFG=/var/www/html/pywps/pywps.cfg
export PYWPS_PROCESSES=/var/www/html/pywps/processes/
/usr/local/bin/wps.py $1
```
# Creating functions
It is not the name of the python script, but the name of the "Class" defined within that determines the name of the service.
# Setting up Flask with Apache
http://alex.nisnevich.com/blog/2014/10/01/setting_up_flask_on_ec2.html