Project

General

Profile

DataPortalDeveloperEnvironmentSetupLinux » History » Revision 41

Revision 40 (Andreas Kohlbecker, 04/25/2018 02:40 PM) → Revision 41/91 (Andreas Kohlbecker, 04/25/2018 03:02 PM)

# Local dataportal development and test environment on Debian based Linux 

 {{>toc}} 

 Install PHP packages 

 ~~~ 
 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 
 ~~~ 

 Restart apache 

 ~~~ 
 sudo service apache2 restart  
 ~~~ 

 ## Local data portal installation 

 1. get latest drupal from http://cybertaxonomy.eu/download/dataportal/stable/    (drupal7-cdm_dataportal-x.x.x.tar.gz)  
 1. extract to `/var/www`  

  **NOTE:** It would be better to install it in sub folder of `~/@, e.g.    @~/workspaces/www/drupal7-cdm_dataportal@, this however would involve that you modify the @/etc/apache2/sites-available/default` accordingly. 

 1. Go to `/var/www/drupal/sites/all`  
 1. delete `/themes`  
 1. insert symlink to checked out themes from svn (http://dev.e-taxonomy.eu/svn/trunk/drupal/7.x/themes/) 

 ~~~ 
 sudo ln -s /path/to/svn/drupal/7.x/themes/ themes 
 ~~~ 

 1. delete `/modules/cdm_dataportal`  
 1. insert symlink to checked out cdm_dataportal modules from svn (http://dev.e-taxonomy.eu/svn/trunk/drupal/7.x/modules) 

 ~~~ 
 sudo ln -s /path/to/svn/drupal/7.x/modules/cdm_dataportal/ modules/cdm_dataportal 
 ~~~ 

 1. Go to `/var/www/drupal/profiles`  
 1. delete `/CDM_DataPortal` and `CDM_DataPortal_Testing`  
 1. insert symlink to checked out profiles from svn (http://dev.e-taxonomy.eu/svn/trunk/drupal/7.x/modules/cdm_dataportal/profile/) 

 ~~~ 
 sudo ln -s /path/to/svn/drupal/7.x/modules/cdm_dataportal/profile/CDM_Portal/ CDM_Portal 
 sudo ln -s /path/to/svn/drupal/7.x/modules/cdm_dataportal/profile/CDM_Portal_Testing/ CDM_Portal_Testing 
 ~~~ 

 1. change ownership of drupal folder to www-data 

 ~~~ 
  sudo chown -R www-data:www-data /var/www/drupal/. <-- not sure what ownership is necessary but this works 
 ~~~ 

 1. Create database as root: 

  `newSite`  

  if you're not logged in to mysql as root then also: 

 ~~~ 
  GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON newSite.* TO 'username'@'localhost'; 
 ~~~ 

 1. got to localhost/drupal/install.php 


 **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 

 ~~~ 
  $databases = array(); 
  $databases['default']['default'] = array( 
      'driver' => 'mysql', 
      'database' => 'new_site', 
      'username' => 'user', 
      'password' => 'pass', 
      'host' => 'localhost', 
      'prefix' => '', 
   ); 
 ~~~ 

 **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 

 ~~~ 
 mbstring.http_input = pass ; 
 mbstring.http_output = pass ; 
 ~~~ 

 ## Starting local CDM server from workspace 

 Requirements: 

 * 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) 
 * You neet a CDM database (called `cdmDB` in this example) 
 * You need Jetty installed in your workspace (EclipsePreferencesforTeams#RunJettyRun) 


 1. In your run configurations you will find two Jetty Webapp launch configs ("cdmlib-remote-webapp - run" and "cdmlib-remote-webapp - profile") 

 * "cdmlib-remote-webapp - run" will start the local CDM server 
 * if you don't have anything configured yet the following output explains how to configure the CDM data bases for the CDM server 

 ~~~ 
 2014-04-15 13:41:08,244 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - property {cdm.datasource} not found. 
 2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - --> This property can be set in two ways: 
 2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - -->  		 1. as attribute to the ServletContext 
 2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - -->  		 2. as system property e.g. -Dcdm.datasource 
 2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - -->  		 3. in ~/.cdmLibrary/cdmlib-remote.properties 
 2014-04-15 13:41:08,245 ERROR [eu.etaxonomy.cdm.remote.config.AbstractWebApplicationConfigurer] - Stopping application ... 
 ~~~ 

 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@): 

 ~~~ 
 <?xml version="1.0" encoding="UTF-8"?> 
 <beans xmlns="http://www.springframework.org/schema/beans" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
 http://www.springframework.org/schema/context 
 http://www.springframework.org/schema/context/spring-context-2.5.xsd"> 

 <bean id="cdmDB"    lazy-init="true" class="com.mchange.v2.c3p0.ComboPooledDataSource"> 
         <property name="driverClass" value="com.mysql.jdbc.Driver"/> 
         <property name="user" value="user"/> 
         <property name="password" value="password"/> 
         <property name="jdbcUrl" value="jdbc:mysql://localhost/cdmDB?autoReconnect=true&amp;autoReconnectForPools=true&amp;"/> 
     </bean> 

 </beans> 
 ~~~ 

 1. In your "cdmlib-remote-webapp - run" launch configuration add to VM arguments: 

 ~~~ 
 -Dcdm.datasource=cdmDB 
 ~~~ 

 1. To connect the data portal to your local CDM server add the following to `Home -> Administration -> Configuration -> CDM Dataportal` and choose your classification 

 ~~~ 
 http://localhost:8080/ 
 ~~~ 

 # Xdebug 

 install Xdebug: 

 ~~~ 
 pecl install xdebug 
 ~~~ 

 at the end of the install log, pecl shows something like: 

 ~~~ 
 Build process completed successfully 
 Installing '/usr/lib/php/20151012/xdebug.so' 
 install ok: channel://pecl.php.net/xdebug-2.6.0 
 configuration option "php_ini" is not set to php.ini location 
 You should add "zend_extension=/usr/lib/php/20151012/xdebug.so" to php.ini 
 ~~~ 


 add xdebug to the php.ini: `/etc/php/7.0/apache2/php.ini` **Use the xdebug.so location from the pecl output**. 

 ~~~ 
 zend_extension=/usr/lib/php/20151012/xdebug.so 
 xdebug.idekey=PHPSTORM 
 xdebug.remote_enable=1 
 xdebug.remote_port=9008 
 ~~~ 

 ~~~ 
 service apache2 reload 
 ~~~ 

 # Setup of PhpStorm 

 

 ## Workspace setup  

 Add Drupal code base to External libraries 

 ![](phpstorm-external-libraries.png) 

 ## PhpStorm configuration to use Xdebug 

 * [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) 
 * [jetbrains: Browser Debugging Extensions](https://confluence.jetbrains.com/display/PhpStorm/Browser+Debugging+Extensions) 

 Add a remote debug configuration to the localhost 

 ![](phpstorm-remote-debug-config.png) 

 This is the server configuration 

 ![](phpstrom-server-config.png) 

 ![](phpstorm-validate-debugger-configuration.png) 

 install the Firefox extension [Xdebug helper](https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/) 


 make sure the extension is configured to use the api-key `PHPSTORM`: 

 ![](Xdebug-helper-configuration.png ) 

 

 ## Project setup 


 ![deployment_connection](deployment_connection.png) 


 ![deployment_mappingpng](php_servers.png) 

 # Setup of the PDT project in eclipse 

 **PDT is no longer recommended, use PhpStorm instead!** 


 ![](drupal7-core-buildpath.png) 


 ![](drupal7-core-includes.png) 

 ##    PDT launch configuration for Drupal projects  


  **NOTE:** Default debug port is 9000. 


 If the eclipse progress bar stops at 57% with the message "Waiting for the XDebug Session" check if `xdebug.remote_enable=on` is set in your php.ini (or xdebug.ini) 


 To see where the ini files are located type 

 ~~~ 
 php --ini 
 ~~~ 

 You may also look here for other troubleshooting: https://stackoverflow.com/questions/9534302/waiting-for-the-xdebug-session-57-in-eclipse-pdt