Project

General

Profile

Download (10.5 KB) Statistics
| Branch: | Tag: | Revision:
1
# CDM Data Portal
2

    
3
Drupal 7 modules and themes as web frontend to publish data hosted in a [cdm server](https://github.com/cybertaxonomy/cdm-server).
4

    
5
This project has a monolithic structure, that is it contains multiple projects in one git repository.
6

    
7
Project dependencies required for bundling the final installation package are managed via composer. 
8
Dependencies of sub-projects like *modules/cdm_dataportal*, *themes/zen_dataportal*, etc still have manually copied dependencies. 
9

    
10
## Project structure
11

    
12
* `./drush`: commands, configuration and site aliases for Drush
13
* `./debug`: scripts that help debugging problems with drupal multisite setups
14
* `./modules`: drupal modules, the actual **cdm_dataportal** module is found here. 
15
* `./scripts/composer`: scripts, installed by composer and manually added ones
16
* `./scripts/jenkins-ci`: scripts for testing, release, deployment in jenkins.
17
* `./site`: documentation source code, will be build by maven (see `pom.xml`)
18
* `./src`: java project with selenium tests
19
* `./themes`: drupal themes
20

    
21
**Generated folders which must not be comitted to the repository:**
22

    
23
* `./target`: target folder of maven, used for the side documentation (source in `./site`) and selenium tests (source in `./src`)
24
* `./screenshots`: screenshots taken during the selenium test execution
25
* `./vendor`: composer cache
26
* `./web`: final installation bundle of drupal 7 with modules, themes, profiles, etc. that is created by `composer update`
27

    
28
**Creation of the composer project**
29

    
30
The parent composer project (`./composer.json`) has been created using the official drupal project template:
31

    
32
~~~
33
composer create-project drupal-composer/drupal-project:7.x-dev -n dist
34
~~~
35

    
36
### On using composer with drupal projects
37

    
38
https://www.drupal.org/docs/develop/using-composer/using-composer-to-install-drupal-and-manage-dependencies
39

    
40
https://www.drupal.org/docs/develop/using-composer/using-composer-with-drupal
41

    
42
https://www.drupal.org/docs/develop/using-composer/managing-dependencies-for-a-custom-project
43

    
44

    
45

    
46
### Installation
47

    
48
**NOTE:** For detailed instructions which also cover the setup of apache and mysql please refer 
49
to: https://cybertaxonomy.eu/dataportal/installation
50

    
51
#### Download & extract
52

    
53
Download the latest release from https://cybertaxonomy.eu/download/dataportal/stable/ to the location where you want 
54
to install the cdm-dataportal Drupal 7 project e.g.
55

    
56
~~~
57
cd /var/www
58
wget https://cybertaxonomy.eu/download/dataportal/stable/drupal-7-cdm-dataportal-5.23.0.tar.gz
59
~~~
60

    
61
This archive contains a shallow clone of the whole project together with a ready to use drupal 7 installation with the 
62
cdm-dataportal module, zen_dataportal theme and other requirements. The drupal-7 installation is in the sub folder `./web`
63

    
64
extract and adapt the ownership of the some folders:
65

    
66
~~~
67
tar -xzf drupal-7-cdm-dataportal-5.23.0.tar.gz
68
./drupal-7-cdm-dataportal/scripts/admin/fix-permissions.sh  --web-user www-data
69
~~~
70

    
71
##### Apache2 configuration
72

    
73
Install required modules
74

    
75
~~~
76
sudo a2enmod headers
77
sudo a2enmod ssl
78
sudo a2enmod rewrite
79
~~~
80

    
81

    
82
You may now want to copy the apache 2 site configuration files from `scripts/apache2.4/` to `/etc/apache2/sites-available/` 
83
and to activate one of them, preferably the ssl site configuration:
84

    
85
~~~
86
cd /var/www
87
sudo cp drupal-7-cdm-dataportal/scripts/apache2.4/dataportal.test* /etc/apache2/sites-available/
88
sudo a2ensite dataportal.test-ssl.conf
89
sudo a2ensite dataportal.test.conf
90
sudo systemctl restart apache2
91
~~~
92

    
93
You may now want to add the hostname to the `/etc/hosts` file:
94

    
95
~~~
96
echo "127.0.0.1 dataportal.test" | sudo tee -a  /etc/hosts
97
~~~
98

    
99
**NOTE**: The virtual host `dataportal.test` is only suitable for development purposes.
100
For production systems you will need to rename the virtual host so that it matches a public host name.
101

    
102
 Site installation
103

    
104
Now you are prepared to install a dataportal drupal site. 
105

    
106
A template for the below script can be found in `scripts/user/`
107
Make an executable copy from `new-site.sh.template` as `new-site.sh` 
108

    
109
~~~
110
cp new-site.sh.template new-site.sh; chmod u+x new-site.sh
111
~~~
112

    
113
Adapt the below shown variables in the script to match your desired setup:
114

    
115
~~~
116
################################################################
117
## Configure below variables
118

    
119
SITE_NAME='test-site'
120

    
121
# HOST_NAME and PROTOCOL determine the base URL of the new site
122
# The default values will form the base URL like http://dataportal.test
123
# See also MULTI_SITE below
124
HOST_NAME='dataportal.test'
125
PROTOCOL='https' # values 'http' ot https'
126
# For MULTI_SITE=0 the site will be installed at the base BASE_URL
127
# In multisite setups (MULTI_SITE=1), however, the site URL results 
128
# in http://dataportal.test/test-site
129
# !! Mutisite support ist still experimental !!
130
MULTI_SITE=0 # values: 1 = true, 0 or other = false
131

    
132
ADMIN_USR='admin'
133
ADMIN_PWD='change--me'
134
ADMIN_EMAIL='admin@dataportal.test'
135

    
136
MYSQL_USR='root'
137
MYSQL_PWD='change--me'
138
DB_PREFIX='drupal7_dataportal_'
139

    
140

    
141
################################################################
142
~~~
143

    
144
Execute the script **from within the folder** `scripts/user/`, otherwise the `$DRUPAL_ROOT` variable will not match the `./web` folder !
145

    
146
Once the script has fished it will print out the final URL of the new site together with other useful information.
147

    
148
### Update - method 1
149

    
150
**Strategy**: Downloading of the installation package for a new release of the cdm-dataportal and replacing the old 
151
installation by the content of the installation package.
152

    
153
* Pro: Few simple steps.
154
* Con: The steps described here are not suitable for multi-site installation or when additional modules are installed.
155

    
156
~~~
157
cd /var/www
158
mv drupal-7-cdm-dataportal drupal-7-cdm-dataportal.last
159
~~~
160

    
161
remove old installation packages
162

    
163
~~~
164
rm drupal-7-cdm-dataportal*.tar.gz*
165
~~~
166

    
167
now follow the steps in the chapter **Download & extract** above.
168

    
169
finally copy the default site to the new installation 
170

    
171
~~~
172
cp -r drupal-7-cdm-dataportal.last/web/sites/default/ drupal-7-cdm-dataportal/web/sites/
173
~~~
174

    
175
apply any pending database updates
176

    
177
~~~
178
drush updatedb
179
drush cc all
180
~~~
181

    
182
Once you have confirmed that the updated installation is working correctly:
183

    
184
~~~
185
rm -r drupal-7-cdm-dataportal.last
186
~~~
187

    
188
### Update - method 2
189

    
190
**Strategy**: In-place updating of the installation by making use of git and drush or composer. 
191

    
192
*THIS METHOD IS RECOMMENDED FOR MOST SITUATIONS**
193

    
194
* Pro: Update of drupal and custom modules independent of what is provided by the installation package.
195
* Con: Initial preparation is more complex, 
196

    
197
#### Preparation
198

    
199
**Install composer v 1.10.x**
200

    
201
!!! *Composer v2.x would fail to preserve existing site installations* !!!
202

    
203
In case the version provided by apt is too old (<1.10), you can install composer manually in the project 
204
directory `/var/www/drupal-7-cdm-dataportal`. In the following we assume you have installed composer this way and 
205
will use `./composer` instead of `composer`.
206

    
207
~~~
208
cd /var/www/drupal-7-cdm-dataportal
209
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
210
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
211
php composer-setup.php --filename=composer --version 1.10.22
212
php -r "unlink('composer-setup.php');"
213
~~~
214

    
215
The above commands fails with "Installer corrupt"? Please update the corresponding command with the new one from [http//getcomposer.org/download/](http//getcomposer.org/download/). It is **important not use use a version > 1.*!**
216

    
217
**Un-shallow the installation package**
218

    
219
The installation package contains a shallow clone of the git repository only. In order to easily upgrade the 
220
dataportal-module it is highly recommended to un-shallow the git repository clone
221

    
222
~~~
223
git fetch --unshallow
224
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
225
git fetch origin
226
git checkout origin/master
227
~~~
228

    
229
**install dependencies**
230

    
231
This will also install **drush**
232

    
233
~~~
234
 ./composer install --no-dev
235
~~~
236

    
237
#### Updating to a specific cdm-dataportal release
238

    
239
NOTE: The modules and themes in the `./web/sites/all/` are sym-linked to the source code in `./modules` and `./themes`. 
240
Hence, updating the dataportal only involves checking out the according release from the git remote:
241

    
242
To see the list of available release tags:
243

    
244
~~~
245
git tag --list | egrep '[0-9]+\.[0-9]+\.[0-9]+' | sort -V
246
~~~
247

    
248
Checkout the release tag. For example to checkout the release `5.23.0`:
249

    
250
~~~
251
git checkout 5.23.0
252
scripts/admin/fix-permissions --web-user www-data
253
~~~
254

    
255
Git will respond with a warning that "*You are in 'detached HEAD' state.*", this is OK and no need to be concerned.
256

    
257
Finally apply any pending database updates and clear the cache. **NOTE**: Below we assume that the command is being 
258
executed in the installation package root e.g. `/var/www/drupal-7-cdm-dataportal` and that the site is available under 
259
https://dataportal.test. Please adapt to your specific settings if needed.
260

    
261
~~~
262
./vendor/drush/drush/drush -r /var/www/drupal-7-cdm-dataportal/web/ -l https://dataportal.test updatedb
263
./vendor/drush/drush/drush -r /var/www/drupal-7-cdm-dataportal/web/ -l https://dataportal.test cc all
264
~~~
265

    
266
#### Updating drupal and modules
267

    
268
The drupal-7-cdm-dataportal installer provides a script for convenient and secure updating of single or multisite setups.
269
It will 
270

    
271
1. create backups
272
1. set the site(s) to maintenance mode   
273
1. Update drupal core and contributed modules via `composer`
274
1. Run any pending database updates and clear the caches
275

    
276
A brief help for this script is available from `scripts/admin/update-dependencies.sh --help` 
277

    
278
~~~
279
USAGE: update-dependencies.sh [--deactivate-install] [--multi-site] [--mailto <ADDRESS>]
280
  --deactivate-install :  The install.php will be hidden by appending '.off' to the filename
281
  -h, --help:  Print this help text
282
  --mailto <ADDRESS>:  send a email to the ADDRESS with a log of the update process
283
  --multi-site:  Do a multi-site update. Requires dataportals-drush. 
284
        See https://dev.e-taxonomy.eu/svn/trunk/server-scripts/dataportal-admin/
285
  --site-url:  The site url to be used with drush. This option disables the --multi-site option
286
~~~
287

    
288

    
289

    
290
Update a single site installation with default site URL
291

    
292
~~~
293
scripts/admin/update-dependencies.sh --deactivate-install 
294
~~~
295

    
296
Update a single site installation with custom site URL
297

    
298
~~~
299
scripts/admin/update-dependencies.sh --deactivate-install --site-url http://edit.test/d7/cichorieae/ 
300
~~~
301

    
302
Update a multi-site installation with custom site URL
303

    
304
~~~
305
scripts/admin/update-dependencies.sh --deactivate-install --multi-site
306
~~~
(3-3/5)