aboutsummaryrefslogtreecommitdiff
path: root/INSTALL-DEV
blob: 3ba9ff514f91ad6d07ff7c3ee1c65ee35d126498 (plain)
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
The goal of this setup is to run the brep Apache2 modules from the development
build while still being as close to the real deployment as possible. To this
end, we use default, system-wide installations of both Apache2 and Postgres.

In the below instructions replace <user> with your login and www-data with the
user under which Apache2 is running (See the "User" directive in the Apache2
.conf file).


0. Check Permissions

Check that the files in the brep/ directory are readable by "others". If they
are not, then run the following two commands to grant Apache2 read access:

setfacl -Rdm g:www-data:rx brep
setfacl -n -Rm g:www-data:rx brep

And also for all the directories leading up to brep/, for example, if you have
~/projects/brep/, then:

setfacl -m g:www-data:rx ~/ ~/projects

[Note that strictly speaking www-data in the above two commands is the Apache2
group, not user. However, most installations use the same name for both.]


1. Create PostgreSQL User and Database

$ sudo sudo -u postgres psql # Note: double sudo is not a mistake.

CREATE DATABASE brep TEMPLATE template0 ENCODING 'UTF8' \
LC_COLLATE 'en_US.UTF8' LC_CTYPE 'en_US.UTF8';
CREATE USER <user>;
GRANT ALL PRIVILEGES ON DATABASE brep TO <user>;
CREATE USER "www-data" INHERIT IN ROLE <user>;

Exit psql (^D), then make sure the logins work:

$ psql -d brep
$ sudo sudo -u www-data psql -d brep

To troubleshoot, see PostgreSQL logs, for example:

$ sudo tail -f /var/log/postgresql/*.log


2. Create Database Schema and Load the Repository

All the commands are executed from brep project root.

$ psql --quiet -d brep -f brep/package.sql
$ loader/brep-loader tests/loader/r.conf # Or some other loader config.

To verify:

$ psql -d brep -c 'SELECT name, summary FROM repository'


3. Setup Apache2 Module

Here we assume Apache2 is installed and you have an appropriate VirtualServer
ready (the one for the default site is usually a good candidate). Open the
corresponding Apache2 .conf file and add the following inside VirtualServer,
replacing <BREP-OUT-ROOT> and <BREP-SRC-ROOT> with the actual absolute paths
(if you built brep in the source tree, then the two would be the same).

        # Load the brep module.
        #
        LoadModule brep_module <BREP-OUT-ROOT>/brep/mod_brep.so

        # Repository root. Use / for web server root. And don't forget to also
        # update the Location and Alias directives below.
        #
        brep-root /pkg

        <Location "/pkg">
          SetHandler brep

          <IfModule dir_module>
            DirectoryIndex disabled
            DirectorySlash Off
          </IfModule>
        </Location>

        # Brep module configuration.
        #
        brep-conf <BREP-SRC-ROOT>/etc/brep-module.conf

        # Static brep content (CSS files).
        #
        # Note: trailing slashes are important!
        #
        Alias /pkg/@/ <BREP-SRC-ROOT>/www/

        <Directory "<BREP-SRC-ROOT>/www">
            Require all granted
        </Directory>

You may want to replace <BREP-SRC-ROOT>/etc/brep-module.conf with a custom
configuration file if you often need to modify it.

Restart Apache2 (use the second version for systemd):

$ sudo /etc/init.d/apache2 restart
$ sudo systemctl restart apache2

To verify, visit the repository root. To troubleshoot, see Apache logs, for
example:

$ sudo tail -f /var/log/apache2/error.log


4. Reloading During Development

To do a "complete reload" (i.e., recreate database schema, load the repository
data, and reload the Apache2 plugin), execute the following from brep/:

psql --quiet -d brep -f brep/package.sql
loader/brep-loader tests/loader/r.conf
sudo /etc/init.d/apache2 restart