Actions

Difference between revisions of "Developer Area/Developer Environment"

From Mahara Wiki

< Developer Area
Line 179: Line 179:
  
 
  sudo -u postgres pg_dump -Fc mahara-14stable > 14stable.pg
 
  sudo -u postgres pg_dump -Fc mahara-14stable > 14stable.pg
 +
sudo -u postgres createdb -Omaharauser mahara-15stable
 
  sudo -u postgres pg_restore -d mahara-15stable < 14stable.pg
 
  sudo -u postgres pg_restore -d mahara-15stable < 14stable.pg
  
Line 185: Line 186:
 
  sudo -u postgres psql mahara-15stable
 
  sudo -u postgres psql mahara-15stable
 
  delete from config where field = 'wwwroot';
 
  delete from config where field = 'wwwroot';
  Ctrl + c to exit
+
  Ctrl + d to exit
  
 
4. create the config file ~/code/mahara/htdocs/config.php
 
4. create the config file ~/code/mahara/htdocs/config.php
Line 207: Line 208:
 
   
 
   
 
  $cfg->sendemail = true;
 
  $cfg->sendemail = true;
  $cfg->sendallemailto = '<your email address';
+
  $cfg->sendallemailto = 'your email address';
 
   
 
   
 
  $cfg->log_dbg_targets    = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
 
  $cfg->log_dbg_targets    = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
Line 219: Line 220:
  
 
  sudo cp -r /var/lib/maharadata/14stable /var/lib/maharadata/15stable
 
  sudo cp -r /var/lib/maharadata/14stable /var/lib/maharadata/15stable
  sudo chown -R www-data:www-data /var/lib/maharadata/15stable
+
  sudo chown -R www-data:www-data /var/lib/maharadata/15stable
  
 
6. add a new entry to /etc/hosts:
 
6. add a new entry to /etc/hosts:

Revision as of 10:56, 6 March 2012

Initial installation of your developer environment on your computer

1. install required packages:

sudo apt-get install libapache2-mod-php5 postgresql git php5-pgsql php5-gd php5-curl gitk

2. do a checkout of the code:

cd ~
mkdir code
cd code
git clone git://gitorious.org/mahara/mahara.git

3. make sure the code checkout is accessible to Apache:

sudo chmod a+rx /home/<your username>

4. create a db user and database:

sudo -u postgres createuser -P -D -R -S maharauser
(use "mahara" as the password)
sudo -u postgres createdb -Omaharauser mahara-master

5. create the config file ~/code/mahara/htdocs/config.php containing:

<?php
$cfg = new StdClass;

$branch = 'master';

// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype   = 'postgres8';
$cfg->dbhost   = 'localhost';
$cfg->dbuser   = 'maharauser';
$cfg->dbname   = "mahara-$branch";
$cfg->dbpass   = 'mahara'; 
$cfg->dbprefix = ''; 

$cfg->dataroot = "/var/lib/maharadata/$branch";

$cfg->sendemail = true;
$cfg->sendallemailto = '<your email address';

$cfg->log_dbg_targets     = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_info_targets    = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_warn_targets    = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_environ_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->perftofoot = true;

6. create a sitedata directory:

sudo mkdir /var/lib/maharadata
sudo mkdir /var/lib/maharadata/master
sudo chown www-data:www-data /var/lib/maharadata/master

7. add a new entry to /etc/hosts:

127.0.0.1 mahara

8. set the following in /etc/php5/apache2/php.ini:

post_max_size = 32M

9. create a new Apache vhost file in /etc/apache2/sites-available/mahara:

<VirtualHost *:80>
 ServerName mahara
 DocumentRoot /home/<your username>/code/mahara/htdocs

 <Directory /home/<your username>/code>
   Options Indexes FollowSymLinks MultiViews
   Order allow,deny
   Allow from all
 </Directory>

 ErrorLog /var/log/apache2/error.log
 LogLevel info

 CustomLog /var/log/apache2/access.log combined
 DirectoryIndex index.php index.html
</VirtualHost>

10. enable the site in Apache:

sudo a2ensite mahara
sudo apache2ctl configtest
sudo apache2ctl graceful

11. Go to the site in your browser to run the Mahara installer:

http://mahara/

Adding another branch

1. create a new local branch for it in git:

cd ~/code/mahara
git checkout -t origin/1.4_STABLE

2. create sitedata for the new branch:

sudo mkdir /var/lib/maharadata/14stable
sudo chown www-data:www-data /var/lib/maharadata/14stable

3. create a database:

sudo -u postgres createdb -Omaharauser mahara-14stable

4. change your ~/code/mahara/htdocs/config.php to point to the 1.4 branch:

$branch = '14stable';

5. Go to the site in your browser to run the Mahara installer:

http://mahara/


Switching back to the master branch

1. change the config.php file:

$branch = 'master';

2. switch to the right git branch:

cd ~/code/mahara/
git checkout master


Reset the database

1. delete the old database

sudo -u postgres dropdb mahara-master

2. create a new one with the same name

sudo -u postgres createdb -Omaharauser mahara-master

3. Go to the site in your browser o run the Mahara installer again:

http://mahara/


Testing a change submitted to Gerrit

1. go to the change page, for example:

https://reviews.mahara.org/#change,230

2. in your local repository, switch to the branch listed in the Gerrit change (in this case: master):

cd ~/code/mahara
git checkout master

3. update your config.php to use the right branch, too

4. copy the "Anonymous Git" URL in the "Download" section of "Patch Set X" and run it in ~/code/mahara to check the branch out:

git fetch git://reviews.mahara.org/git/mahara refs/changes/30/230/1 && git checkout FETCH_HEAD

5. after finishing the testing, go back to master:

git checkout master

Copying a local install to another

This example uses the directory 15stable as an example for the new install and the 14stable install as database and sitedata directory to copy.

1. do a checkout of the code into a new directory

cd ~
mkdir code
cd code
git clone git://gitorious.org/mahara/mahara.git 15stable

2. copy the database

sudo -u postgres pg_dump -Fc mahara-14stable > 14stable.pg
sudo -u postgres createdb -Omaharauser mahara-15stable
sudo -u postgres pg_restore -d mahara-15stable < 14stable.pg

3. change the wwwroot in the new database

sudo -u postgres psql mahara-15stable
delete from config where field = 'wwwroot';
Ctrl + d to exit

4. create the config file ~/code/mahara/htdocs/config.php


<?php
$cfg = new StdClass;

$branch = '15stable';

// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype   = 'postgres8';
$cfg->dbhost   = 'localhost';
$cfg->dbuser   = 'maharauser';
$cfg->dbname   = "mahara-$branch";
$cfg->dbpass   = 'mahara'; 
$cfg->dbprefix = ''; 

$cfg->dataroot = "/var/lib/maharadata/$branch";

$cfg->sendemail = true;
$cfg->sendallemailto = 'your email address';

$cfg->log_dbg_targets     = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_info_targets    = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_warn_targets    = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->log_environ_targets = LOG_TARGET_SCREEN | LOG_TARGET_ERRORLOG;
$cfg->perftofoot = true;

5. copy the o sitedata directory:

sudo cp -r /var/lib/maharadata/14stable /var/lib/maharadata/15stable
sudo chown -R www-data:www-data /var/lib/maharadata/15stable

6. add a new entry to /etc/hosts:

127.0.0.1 15stable

7. create a new Apache vhost file in /etc/apache2/sites-available/15stable:

<VirtualHost *:80>
 ServerName 15stable
 DocumentRoot /home/<your username>/code/15stable/htdocs

 <Directory /home/<your username>/code>
   Options Indexes FollowSymLinks MultiViews
   Order allow,deny
   Allow from all
 </Directory>

 ErrorLog /var/log/apache2/error.log
 LogLevel info

 CustomLog /var/log/apache2/access.log combined
 DirectoryIndex index.php index.html
</VirtualHost>

8. enable the site in Apache:

sudo a2ensite 15stable
sudo apache2ctl configtest
sudo apache2ctl graceful

9. Go to the site in your browser to run the Mahara installer:

http://15stable/