Project

General

Profile

DataPortalDeveloperEnvironmentSetupLinux » History » Version 82

Andreas Kohlbecker, 01/09/2020 05:38 PM

1 17 Patrick Plitzner
# Local dataportal development and test environment on Debian based Linux
2 1 Andreas Kohlbecker
3 34 Andreas Kohlbecker
{{>toc}}
4 33 Andreas Kohlbecker
5 51 Andreas Kohlbecker
## Install PHP packages
6 23 Patrick Plitzner
7 1 Andreas Kohlbecker
~~~
8 26 Patrick Plitzner
sudo apt-get install php libapache2-mod-php php-cli php-common php-curl php-gd php-mcrypt php-mysql php-xdebug php-json php-xml php-mbstring
9 25 Patrick Plitzner
~~~
10 1 Andreas Kohlbecker
11 51 Andreas Kohlbecker
copy attachment:edit.test.conf to `/etc/apache2/sites-available/`
12
13 81 Patrick Plitzner
open `/etc/apache2/sites-available/edit.test.conf` and replace all `{USER_NAME}` with your home folder resp. the output of `echo $USER`
14 51 Andreas Kohlbecker
15 60 Andreas Kohlbecker
add the following line to `/etc/hosts`
16
17
~~~
18
127.0.0.1   edit.test
19
~~~ 
20
21 68 Andreas Kohlbecker
create the workspace folder
22
23
~~~
24 78 Patrick Plitzner
mkdir ~/workspaces/
25 68 Andreas Kohlbecker
mkdir ~/workspaces/www/
26
~~~
27
28 53 Andreas Kohlbecker
enable the test vhost:
29
30 51 Andreas Kohlbecker
~~~
31 1 Andreas Kohlbecker
sudo chown root:root /etc/apache2/sites-available/edit.test.conf
32 59 Patrick Plitzner
sudo a2enmod rewrite
33 50 Andreas Kohlbecker
sudo a2ensite edit.test.conf
34 51 Andreas Kohlbecker
sudo systemctl restart apache2.service  
35 1 Andreas Kohlbecker
~~~
36
37 68 Andreas Kohlbecker
38 51 Andreas Kohlbecker
**Check if php is working:**
39 1 Andreas Kohlbecker
40 52 Andreas Kohlbecker
Copy attachment:info.php  in the http root (e.g. ~/workspaces/www/) and open http://edit.test/info.php in your browser
41 1 Andreas Kohlbecker
42 51 Andreas Kohlbecker
## Install Drush
43 1 Andreas Kohlbecker
44
http://docs.drush.org/en/8.x/install/
45
46
## Local data portal installation
47
48 53 Andreas Kohlbecker
create the cdm_dataportal workspace:
49
50 1 Andreas Kohlbecker
~~~
51 69 Andreas Kohlbecker
mkdir ~/workspaces/cdm
52
cd ~/workspaces/cdm
53 62 Patrick Plitzner
git clone ssh://git@dev.e-taxonomy.eu/var/git/cdm-dataportal.git
54 53 Andreas Kohlbecker
~~~ 
55
56
now you should have the folder `~/workspaces/cdm/cdm-dataportal`
57
58 79 Patrick Plitzner
Switch to the develop branch
59
60
~~~
61
git checkout develop
62
~~~
63
64 53 Andreas Kohlbecker
install drupal core:
65
66 1 Andreas Kohlbecker
~~~
67 68 Andreas Kohlbecker
cd ~/workspaces/www/
68 1 Andreas Kohlbecker
drush dl drupal-7.x  
69 74 Andreas Kohlbecker
drush dl admin_menu backup_migrate ctools devel drupal_maintenance_block i18n imce imce_wysiwyg l10n_update languageicons module_missing_message_fixer smtp variable wysiwyg wysiwyg_codemagic
70 1 Andreas Kohlbecker
~~~
71
72 63 Patrick Plitzner
setup the cdm_dataportal by creating symlinks to the according folders in the cdm_dataportal workspace
73 1 Andreas Kohlbecker
74
~~~
75 68 Andreas Kohlbecker
cd ~/workspaces/www/drupal-7.x-dev/
76 69 Andreas Kohlbecker
ln -s ~/workspaces/cdm/cdm-dataportal/themes/zen_dataportal/polyfills
77
ln -s ~/workspaces/cdm/cdm-dataportal/debug/db_debug.php.inc
78
ln -s ~/workspaces/cdm/cdm-dataportal/debug/drupal_site_debug.php
79 68 Andreas Kohlbecker
rm -rf  ~/workspaces/www/drupal-7.x-dev/sites/all/themes 
80
cd ~/workspaces/www/drupal-7.x-dev/profiles
81 69 Andreas Kohlbecker
ln -s ~/workspaces/cdm/cdm-dataportal/modules/cdm_dataportal/profile/CDM_Portal CDM_Portal
82
ln -s ~/workspaces/cdm/cdm-dataportal/modules/cdm_dataportal/profile/CDM_Portal_Testing/ CDM_Portal_Testing
83 7 Patrick Plitzner
~~~
84 53 Andreas Kohlbecker
85 69 Andreas Kohlbecker
Delete `~/workspaces/www/drupal-7.x-dev/modules/cdm_dataportal` if it exists (it should not!!!)
86 1 Andreas Kohlbecker
87
88
change group ownership of drupal folder to www-data
89 65 Patrick Plitzner
90 7 Patrick Plitzner
~~~
91 68 Andreas Kohlbecker
sudo chown -R :www-data ~/workspaces/www/drupal-7.x-dev/
92 1 Andreas Kohlbecker
~~~
93
94 7 Patrick Plitzner
## Create a site
95 1 Andreas Kohlbecker
96 80 Patrick Plitzner
Each new site must be added to the ~/workspaces/www/drupal-7.x-dev/sites/sites.php. We recommend using the following php code to generate the correct site information in the sites.php:
97 71 Andreas Kohlbecker
98
~~~php
99
100
$portal_names = array('my-first-site', 'my-second-site', 'new-site');
101
102
$portal_site_prefixes = array(
103
	'edit.test.d7'
104
);
105
106
$sites = array();
107
108
foreach ($portal_site_prefixes as $prefix) {
109
  foreach ($portal_names as $name) {
110
    $sites[$prefix . '.' . $name] = $name;
111
  }
112
}
113
~~~
114
115 73 Andreas Kohlbecker
The drupal sites will be available at http://edit.test/d7/{site_name}/. A per site configuration in apache is not needed since the virtual host configuration file `edit.test.conf` contains a `AliasMatch` directive which will make all drupal sites available under `http://edit.test/d7/`:
116
117
~~~
118
AliasMatch ^/d7/([^/]+)(.*)		/home/your-user-name/workspaces/www/drupal-7$2
119
~~~
120
121 72 Andreas Kohlbecker
In order to test your site.php copy the attachment:sites-debug.php into the sites folder and execute it with php:
122
123
~~~
124
php sites/sites-debug.php`
125
~~~
126 71 Andreas Kohlbecker
127 56 Andreas Kohlbecker
#### clone an existing site site from a server
128
129 68 Andreas Kohlbecker
copy the according site folder to `~/workspaces/www/drupal-7.x-dev/sites/new_site`
130 56 Andreas Kohlbecker
131
restore a dump of the according mysql database
132 66 Patrick Plitzner
133 68 Andreas Kohlbecker
edit `~/workspaces/www/drupal-7.x-dev/sites/sites.php` to add your site
134 61 Andreas Kohlbecker
135 75 Patrick Plitzner
fix potential problems (drupal-fix-missing-modules.sh is available in `server-scripts/drupal/drupal-fix-missing-modules.sh`) https://dev.e-taxonomy.eu/old/trac/browser/trunk/server-scripts/drupal/drupal-fix-missing-modules.sh, 
136
see also [[CdmDataportalRestoreDumps|How to restore CDM DataPortal database dumps]]
137 1 Andreas Kohlbecker
138 56 Andreas Kohlbecker
~~~
139 58 Andreas Kohlbecker
drupal-fix-missing-modules.sh http://edit.test/d7/new_site/
140
~~~
141 66 Patrick Plitzner
142 58 Andreas Kohlbecker
for trouble shooting (drupal_site_debug.php has been installed above!)
143 1 Andreas Kohlbecker
144
~~~
145 68 Andreas Kohlbecker
cd ~/workspaces/www/drupal-7.x-dev/
146 58 Andreas Kohlbecker
drush -l ${site-ulr} scr ~/drupal_site_debug.php
147 1 Andreas Kohlbecker
~~~
148 58 Andreas Kohlbecker
149 56 Andreas Kohlbecker
#### create a brand new site
150
151 54 Andreas Kohlbecker
in this example the new site is named **"new_site"**
152 1 Andreas Kohlbecker
153 54 Andreas Kohlbecker
~~~
154 68 Andreas Kohlbecker
mkdir ~/workspaces/www/drupal-7.x-dev/sites/new_site 
155
cd ~/workspaces/www/drupal-7.x-dev/sites/new_site 
156
ln -s ~/workspaces/cdm/cdm-dataportal/themes
157 54 Andreas Kohlbecker
mkdir modules
158
cd modules
159 68 Andreas Kohlbecker
ln -s ~/workspaces/cdm/cdm-dataportal/modules/cdm_dataportal
160 54 Andreas Kohlbecker
~~~ 
161 53 Andreas Kohlbecker
162 55 Andreas Kohlbecker
for further steps on setting up a site please refer to https://wiki.bgbm.org/bdinotes/index.php/EDITProductionNewDataPortal#Setup_and_install_the_new_site
163
164 54 Andreas Kohlbecker
======  from here on the documentation is not yet up to date ======
165
166 1 Andreas Kohlbecker
1. Create database as root:
167
168 54 Andreas Kohlbecker
 `new_site` 
169 1 Andreas Kohlbecker
170
 if you're not logged in to mysql as root then also:
171
172
~~~
173 54 Andreas Kohlbecker
 GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON new_site.* TO 'username'@'localhost';
174 28 Andreas Kohlbecker
~~~
175 1 Andreas Kohlbecker
176 4 Andreas Kohlbecker
1. got to localhost/drupal/install.php
177
178 28 Andreas Kohlbecker
179 8 Patrick Plitzner
**NOTE:** If you are having problems with the graphical installer ("page not found" after installation) you may consider editing `/var/www/drupal7-cdm_dataportal/sites/default/settings.php` with the following and repeat all the steps above
180
181
~~~
182
 $databases = array();
183 1 Andreas Kohlbecker
 $databases['default']['default'] = array(
184 8 Patrick Plitzner
     'driver' => 'mysql',
185 1 Andreas Kohlbecker
     'database' => 'new_site',
186
     'username' => 'user',
187
     'password' => 'pass',
188
     'host' => 'localhost',
189
     'prefix' => '',
190 8 Patrick Plitzner
  );
191 26 Patrick Plitzner
~~~
192 28 Andreas Kohlbecker
193 1 Andreas Kohlbecker
**NOTE:** If you see this message "Multibyte string input conversion in PHP is active and must be disabled" then add the following to your *mbstring.ini* or *php.ini* file
194
195 26 Patrick Plitzner
~~~
196
mbstring.http_input = pass ;
197
mbstring.http_output = pass ;
198 8 Patrick Plitzner
~~~
199 10 Patrick Plitzner
200
## Starting local CDM server from workspace
201
202 1 Andreas Kohlbecker
Requirements:
203 28 Andreas Kohlbecker
204
* You need to have cdmlib checked out and imported into your eclipse workspace (http://cybertaxonomy.eu/cdmlib/getting-started.html#Developing_the_CDM_Library_with_Eclipse)
205
* You neet a CDM database (called `cdmDB` in this example)
206 10 Patrick Plitzner
* You need Jetty installed in your workspace (EclipsePreferencesforTeams#RunJettyRun)
207
208
209
1. In your run configurations you will find two Jetty Webapp launch configs ("cdmlib-remote-webapp - run" and "cdmlib-remote-webapp - profile")
210 28 Andreas Kohlbecker
211
* "cdmlib-remote-webapp - run" will start the local CDM server
212 10 Patrick Plitzner
* if you don't have anything configured yet the following output explains how to configure the CDM data bases for the CDM server
213
214
~~~
215
2014-04-15 13:41:08,244 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - property {cdm.datasource} not found.
216
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - --> This property can be set in two ways:
217
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - --> 		1. as attribute to the ServletContext
218
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - --> 		2. as system property e.g. -Dcdm.datasource
219
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - --> 		3. in ~/.cdmLibrary/cdmlib-remote.properties
220
2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - Stopping application ...
221 28 Andreas Kohlbecker
~~~
222 14 Patrick Plitzner
223 1 Andreas Kohlbecker
1. For the second option add a data source bean to your `/home/user/.cdmLibrary/datasources.xml` (<- create file if it does not exist) as follows (do NOT confuse with @/home/user/cdmLibrary/writableResources/cdm.datasources.xml@):
224 10 Patrick Plitzner
225 1 Andreas Kohlbecker
~~~
226 14 Patrick Plitzner
<?xml version="1.0" encoding="UTF-8"?>
227
<beans xmlns="http://www.springframework.org/schema/beans"
228
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
229 1 Andreas Kohlbecker
  xsi:schemaLocation="http://www.springframework.org/schema/beans
230 14 Patrick Plitzner
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
231
http://www.springframework.org/schema/context
232
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
233
234
<bean id="cdmDB"  lazy-init="true" class="com.mchange.v2.c3p0.ComboPooledDataSource">
235 10 Patrick Plitzner
        <property name="driverClass" value="com.mysql.jdbc.Driver"/>
236
        <property name="user" value="user"/>
237
        <property name="password" value="password"/>
238
        <property name="jdbcUrl" value="jdbc:mysql://localhost/cdmDB?autoReconnect=true&amp;autoReconnectForPools=true&amp;"/>
239
    </bean>
240 1 Andreas Kohlbecker
241 14 Patrick Plitzner
</beans>
242 28 Andreas Kohlbecker
~~~
243 10 Patrick Plitzner
244 14 Patrick Plitzner
1. In your "cdmlib-remote-webapp - run" launch configuration add to VM arguments:
245 10 Patrick Plitzner
246
~~~
247 18 Patrick Plitzner
-Dcdm.datasource=cdmDB
248 28 Andreas Kohlbecker
~~~
249 10 Patrick Plitzner
250
1. To connect the data portal to your local CDM server add the following to `Home -> Administration -> Configuration -> CDM Dataportal` and choose your classification
251
252
~~~
253
http://localhost:8080/
254 8 Patrick Plitzner
~~~
255 35 Andreas Kohlbecker
256
# Xdebug
257
258
install Xdebug:
259
260
~~~
261
pecl install xdebug
262
~~~
263 36 Andreas Kohlbecker
264 35 Andreas Kohlbecker
at the end of the install log, pecl shows something like:
265
266
~~~
267
Build process completed successfully
268
Installing '/usr/lib/php/20151012/xdebug.so'
269
install ok: channel://pecl.php.net/xdebug-2.6.0
270
configuration option "php_ini" is not set to php.ini location
271
You should add "zend_extension=/usr/lib/php/20151012/xdebug.so" to php.ini
272
~~~
273
274 37 Andreas Kohlbecker
275 35 Andreas Kohlbecker
add xdebug to the php.ini: `/etc/php/7.0/apache2/php.ini` **Use the xdebug.so location from the pecl output**.
276
277
~~~
278
zend_extension=/usr/lib/php/20151012/xdebug.so
279
xdebug.idekey=PHPSTORM
280
xdebug.remote_enable=1
281
xdebug.remote_port=9008
282
~~~
283
284
~~~
285
service apache2 reload
286
~~~
287 32 Andreas Kohlbecker
288
# Setup of PhpStorm
289 43 Andreas Kohlbecker
290 41 Andreas Kohlbecker
## Workspace setup
291 47 Andreas Kohlbecker
292
Create a Drupal project in phpStorm for the cdm_dataportal project folder:
293
294
295
The  final Directory settings for the project should now look like:
296
297
![](phpstorm-settings-directories.png)
298 42 Andreas Kohlbecker
299
### Add Drupal code base to External libraries
300
301
open the external libraries configuration:
302
303
![](phpstorm-external-libraries-open.png)
304 43 Andreas Kohlbecker
305 41 Andreas Kohlbecker
Setup the paths (this screenshot is only an example):
306
307
![](phpstorm-external-libraries.png)
308 38 Andreas Kohlbecker
309
## PhpStorm configuration to use Xdebug
310
311
* [jetbrains: Zero-configuration Web Application Debugging with Xdebug and PhpStorm](https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm#Zero-configurationWebApplicationDebuggingwithXdebugandPhpStorm-1.InstallXdebug)
312
* [jetbrains: Browser Debugging Extensions](https://confluence.jetbrains.com/display/PhpStorm/Browser+Debugging+Extensions)
313 76 Andreas Kohlbecker
* [jetbrains: Troubleshooting common PHP debugging issues](https://www.jetbrains.com/help/phpstorm/troubleshooting-php-debugging.html)
314 40 Andreas Kohlbecker
315 38 Andreas Kohlbecker
Add a remote debug configuration to the localhost
316
317
![](phpstorm-remote-debug-config.png)
318 45 Andreas Kohlbecker
319 38 Andreas Kohlbecker
This is the server configuration. Do not configure pathmappings for localhost!
320
321 44 Andreas Kohlbecker
![](phpstrom-server-config.png)
322 46 Andreas Kohlbecker
323 44 Andreas Kohlbecker
If you are having problems configuring your debugger, you can use the Web Server Debug Validation tool to solve common problems with your debug configuration. The tool can be started by selecting the Run | Web Server Debug Validation option from the menu.
324 39 Andreas Kohlbecker
325 38 Andreas Kohlbecker
![](phpstorm-validate-debugger-configuration.png)
326
327
install the Firefox extension [Xdebug helper](https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/)
328
329
330
make sure the extension is configured to use the api-key `PHPSTORM`:
331
332
![](Xdebug-helper-configuration.png )
333
334
## Project setup
335
336 32 Andreas Kohlbecker
337
![deployment_connection](deployment_connection.png)
338
339
340
![deployment_mappingpng](php_servers.png)
341 17 Patrick Plitzner
342 82 Andreas Kohlbecker
## Setup for developing and running PHPUnit tests
343 30 Andreas Kohlbecker
344 82 Andreas Kohlbecker
see https://github.com/cybertaxonomy/cdm-dataportal/tree/master/modules/cdm_dataportal/test/phpUnit