This repository has been archived by the owner on Mar 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathINSTALL
286 lines (202 loc) · 8.12 KB
/
INSTALL
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# HOWTO install OS2Webscanner on your own server
## System requirements
We recommend that any server that you wish to use for running this scanner must
have at least 4GB RAM, a CPU with 4 cores and at least as much free disk space
as used by the web sites you want to scan.
*Note:* The installer is currently only set up to work with Debian-like
GNU/Linux systems, as it depends on the `apt` package management system.
Magenta has tested the system on _Ubuntu 12.04 only_, but it should work
without problem on all recent Debian-like systems.
If you wish to run the system on a non-Debian-like GNU/Linux system or on
FreeBSD or OSX, you will have to modify `install.sh` yourself to handle the
package managers, package names and dependencies in these systems. Also note
that the setup of Apache is different on such systems.
*Note:* The Apache configuration file delivered with version 1.1.0 of
OS2Webscanner is for Apache <= 2.2 and will *not* work on Apache 2.4.
A configuration file for Apache 2.4 will be supplied in future versions.
In the meantime, please refer to
http://httpd.apache.org/docs/2.4/upgrading.html for instructions on how to
upgrade the configuration file for running Apache 2.4. As Apache 2.2 is not
available in Ubuntu 14.04, please note that the present instructions will _not_
work without modification in Ubuntu 14.04. We do not recommend running a
production server on non-LTS versions of Ubuntu.
If you wish to run the system on a Windows system, you need to install a C
compiler environment, e.g. MinGW or Cygwin. Running on Windows has not been
tested.
## Select installation directory
We recommend that you install the system as a dedicated user, e.g. with
username `os2`. To proceed with the installation, create the user, prevent
remote login and login as that user:
```
sudo adduser os2
sudo adduser os2 sudo
sudo su - os2
```
Note, you are now logged in as the user `os2`. We assume this in the rest of
this guide. Also note that this is only a convention - you are free to install
the system wherever you want. Paths are not hard coded in the system.
*Note:* You should probably remove `os2`'s sudo rights once the installation is
complete.
## Install Git, Apache and WSGI
```
sudo apt-get install git apache2 libapache2-mod-wsgi
```
## Get the code
```
git clone https://github.com/os2webscanner/os2webscanner.git
```
## Install Django and Scrapy, including system dependencies
```
cd os2webscanner
./install.sh
```
You will be prompted for the `sudo` password.
*Note:* This requires an Internet connection and may take a while.
## Set up the database
If you performed the previous step, you've already installed `postgresql`
and `postgresql-client`.
Assuming this, do:
```
sudo su - postgres
createdb os2webscanner
createuser os2webscanner
psql
```
The following commands must be executed IN psql shell.
```
grant all on database os2webscanner to os2webscanner;
alter user os2webscanner with password '<PASSWORD>';
alter user os2webscanner createdb;
```
You may (of course) use another database name, database user etc. as you
please.
Now log out from psql (`\q`) and logout as the postgres user (by pressing
`Ctrl+D`) to proceed, and return to where you cloned the `os2webscanner` source
directory (e.g. `/home/os2/os2webscanner`).
Next, change into the `webscanner_site/webscanner` directory:
```
cd webscanner_site/webscanner
```
Copy the file `local_settings.py.example` to `local_settings.py` and open
`local_settings.py` for editing:
```
cp local_settings.py.example local_settings.py
<< edit local_settings.py with your favorite editor>>
```
In order to make your database setup work, you must override the default
DATABASES configuration.
A sample `local_settings.py` configured for your server could look like this:
```
SITE_URL = 'http://webscanner.kommune.dk'
STATIC_ROOT = '/home/os2/os2webscanner/webscanner_site/static'
MEDIA_ROOT = '/home/os2/os2webscanner/webscanner_site/uploads'
DEFAULT_FROM_EMAIL = 'your@email'
ADMIN_EMAIL = 'your@email'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'os2webscanner',
'USER': 'os2webscanner',
'PASSWORD': 'YOUR_PASSWORD',
'HOST': '127.0.0.1',
}
}
```
## Test and initialize
```
cd /home/os2/os2webscanner/webscanner_site
source ../python-env/bin/activate
python manage.py test os2webscanner
```
The test should pass. Now do:
```
python manage.py migrate
```
and create a user with a password you can remember.
## Deployment with Apache
First, collect content to be served statically:
```
cd /home/os2/os2webscanner/webscanner_site
python manage.py collectstatic
```
Next, deploy Apache configuration:
```
cd /home/os2/os2webscanner
sudo cp config/apache.conf /etc/apache2/sites-available/webscanner
```
Now, before activating the site, please _edit_ the Apache configuration.
* If you're using SSL, please supply paths to your certificate files.
* Change the `ServerName` directive to the FQDN of your own server.
* If you're not installing to the directory `/home/os2/os2webscanner/`, please
change all paths accordingly.
* If you're _not_ using SSL, please delete the first VirtualHost, specify port
80 for the second one and delete all directives starting with the letters
"SSL".
If using SSL, you need to enable the extensions `mod_rewrite` and `mod_ssl`:
```
sudo a2enmod rewrite
sudo a2enmod ssl
```
You also need to create the Apache log directories:
```
sudo mkdir -p /var/log/os2webscanner/
```
With all this in place, you may now enable the Apache site:
```
sudo a2ensite webscanner
sudo service apache2 restart
```
The webscanner should now be available at the URL you specified as ServerName
in your VirtualHost, e.g. "https://webscanner.kommune.dk".
## Start the scanning processors
First, make the logs directory writable by the web server user:
```
sudo chown -R www-data:os2 /home/os2/os2webscanner/var
```
Next, start the _process manager_ background process in order to get scans
which scan non-text files (e.g. PDF files or Office documents) to work.
```
sudo -u www-data -b /home/os2/os2webscanner/scrapy-webscanner/start_process_manager.sh
```
*Note:* You may want to have the scanners `var` dir somewhere else, e.g. in
`/var/lib/os2webscanner`, which is the location we (the developers) prefer for
production environments. To achieve this, please overwrite the Django setting
`VAR_DIR` in your `local_settings.py` accordingly and set ownership for the
directory as indicated above.
## Setting up scheduled scans
To setup scheduled scans, you need to add an entry to the user www-data's
crontab:
```
sudo crontab -u www-data -e
```
Add the following line below the commented lines (beginning with '#'), and
then save the file:
```
*/15 * * * * /home/os2/os2webscanner/cron/run_cron_script.sh
```
## Setting up scheduled summary reports
The system may send out summary reports describing the performance, results,
etc., of different scanners.
To have summaries emailed to recipients, edit `crontab` as described in the
previous section, adding the line
```
0 7 * * * /home/os2/os2webscanner/cron/dispatch_summaries.sh
```
to have summaries emailed every day at 7AM. You can of course change this as
you wish, but summaries should be mailed no more than once a day as this may
cause reports to be sent twice.
## Creating an organization and adding a user to it:
Visit your webscanner site URL + `/admin/` to enter the Django admin interface.
Login with the Django superuser you created (when running `python manage.py
syncdb`). Click on "Organization" and hit the button labeled "Tilføj
Organisation" or "Add Organization" to add an "Organization". This is
necessary - the system will not work without at least one organization. Give
your new organization a name, email address and phone number and save it by
clicking "Gem" or "Save" at the bottom of the page.
Return to the main admin page and click "Brugere".
Click the username that you would like to add to the organization.
At the bottom of the page, under "User profiles", change the "Organisation"
to the organization you created and save.
OS2Webscanner is now ready to be used.