Difference between revisions of "Activity Library/Devel/Installing"

From Sugar Labs
Jump to: navigation, search
(Test server)
(addons.sugarlabs.org is no longer and only redirectrs to activities.sl.o)
Line 1: Line 1:
 
=Activities.sugarlabs.org=
 
=Activities.sugarlabs.org=
 
Over the last several months, there have been on and off discussions about how to adapt the addons.mozilla.org server software to manage Sugar activities.
 
Over the last several months, there have been on and off discussions about how to adapt the addons.mozilla.org server software to manage Sugar activities.
 
== Surely ADDONS.sugarlabs.org ? ==
 
As of February 2009, http://addons.sugarlabs.org exists (and rocks)! , while http://activities.sugarlabs.org only presents some user directories. -- [[User:Skierpage|Skierpage]] 02:14, 22 February 2009 (UTC)
 
  
 
==Background==
 
==Background==

Revision as of 18:41, 26 August 2009

Activities.sugarlabs.org

Over the last several months, there have been on and off discussions about how to adapt the addons.mozilla.org server software to manage Sugar activities.

Background

Information about Remora, the codename for a.m.o version 3, is at https://wiki.mozilla.org/Update:Remora.

Why base a.s.o on a.m.o

Pros

  • The function of a.m.o is exactly the same as the desired functionality of a.s.o.

Cons

  • A.m.o is currently only used by mozilla.
  • A.m.o is written in cake-php (yet another web framework)

Installing activities.sugarlabs.org

Mozilla.org runs a.m.o on CentOS5.0. For capability reasons these instructions will also use CentOS5.2.

Install centOS5.2 as server

It is handy to set up a development system as a server-gui in a virtual machine.

Set up Apache

Apache is pre-installed on CentOS.

Configure Apache to start on system boot.

chkconfig --levels 235 httpd on

Create Apache test page

vim /var/www/html/index.php
<?php phpinfo(); ?>

Start Apache

service httpd start

Install Firefox

yum install firefox

Test 127.0.0.1

verify mod_rewrite and mod_expires are loaded

Set up php

look for PHP5.1.6

rpm -q php

look for php-gettext ( in php-common)

rpm -q php-common

install required php modules

yum install php-pear php-gd php-mbstring
pear config-set preferred_state beta 
pear install Archive_Zip

Install git

yum install git

Checkout our fork

The repo with the latest sources is http://git.sugarlabs.org/projects/slo-activities/repos/mainline

git-clone git://git.sugarlabs.org/slo-activities/mainline.git /var/www

Add these lines to /var/www/.git/info/exclude:

/site/vendors/product-details
/site/app/config/config-local.php
/site/app/config/config.php
/site/app/tmp

Create some empty dirs needed at runtime:

mkdir /var/www/site/app/tmp/
mkdir /var/www/site/app/tmp/cache
mkdir /var/www/site/app/tmp/cache/persistent
mkdir /var/www/site/app/tmp/cache/models
mkdir /var/www/site/app/tmp/cache/views

Fetch one external dependency:

cd /var/www/site/vendors/
svn co http://svn.mozilla.org/libs/product-details product-details

Set up server

Set permissions

chown -R apache:apache /var/www/site 

Edit DocumentRoot

vim /etc/httpd/conf/httpd.conf

Edit DocumentRoot /var/www/site/app/webroot
Edit AllowOverride All

Add to hosts

vim /etc/hosts
127.0.0.1 activities.sugarlabs.org

Test server

service httpd restart

mv /var/www/site/app/webroot/index.php /var/www/site/app/webroot/index.php.old
mv /var/www/html/index.php /var/www/site/app/webroot/index.php

Open

Open activities.sugarlabs.org in firefox

Install mysql

yum install mysql-server php-mysql

start mysql on system boot

chkconfig --levels 235 mysqld on 

Start mysqld

service mysqld start

Test server

service httpd restart

open activities.sugarlabs.org in firefox. Make sure mysql is enabled

Revert index.php

mv /var/www/site/app/webroot/index.php.old /var/www/site/app/webroot/index.php

Setup mysql

mysqladmin -u root password remora
mysqladmin -u root -p create remora
mysql -u root -p
GRANT ALL ON *.* TO 'remora'@'localhost' IDENTIFIED BY 'remora';
exit; 

Configure aso

Auto mode

cd /var/www
aslo/db-create-stub.sh

Manual mode

Populate tables

mysql -u remora --password=remora -D remora </var/www/site/app/config/sql/remora.sql
mysql -u remora --password=remora -D remora </var/www/site/app/tests/data/remora-test-data.sql
mysql -u remora --password=remora -D remora </var/www/site/app/tests/data/sugar-test-data.sql

Edit config.php

cp /var/www/site/app/config/config.php.default /var/www/site/app/config/config.php
vim /var/www/site/app/config/config.php

NOTE Make sugar that /var/www/site/app/config/config.php is ended by "?>" not by "?>\n"

<?php
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is addons.mozilla.org site.
 *
 * The Initial Developer of the Original Code is
 * The Mozilla Foundation.
 * Portions created by the Initial Developer are Copyright (C) 2006
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *   Wil Clouser <wclouser@mozilla.com> (Original Author)
 *   Mike Morgan <morgamic@mozilla.com>
 *   Justin Scott <fligtar@gmail.com>
 *   Frederic Wenzel <fwenzel@mozilla.com>
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */



/**
 * Global configuration document.
 *
 * This document covers both the CakePHP based site (/site) and its service scripts.
 * Unless otherwise noted, trailing slashes should not be used.
 * @package amo
 */

/**
 * Site URL
 * Example: http://addons.mozilla.org
 * Example: http://khan-vm.mozilla.org (dev)
 * Example of getting a full controller url:
 *     echo SITE_URL.$html->url('/users/register');
 * Will default to http://addons.mozilla.org unless defined below
 */
// define('SITE_URL', '');

/**
 * Services URL.
 * Example: http://addons.mozilla.org/services
 * Example: http://khan-vm.mozilla.org/amo/services (dev)
 */
define('SERVICE_URL','http://activities.sugarlabs.org');

/**
 * Site State
 * Example: production
 * Example: staging
 * Example: dev
 * All uses should default to dev
 */
define('SITE_STATE', 'dev');
 
/**
 * Files
 * The application uses these paths to piece together the URL for files.
 *
 * HOST and URL are separated because CakePHP has $html->webroot, and only appends
 * FILES_URL while the services need both since it doesn't have
 * Cake's context.
 *
 * No trailing slashes.
 */

/**
 * Host, including http://.  Should be everything leading up to addon ids.
 * Example: http://releases.mozilla.org/addons
  */
define('FILES_HOST', 'http://activities.sugarlabs.org');       

/**
 * Relative web path of the files directory.  Tacking this on to FILES_HOST should get you
 * the complete URL where your files are. This is the location of the downloads controller
 * and it should not normally need to be changed, the default is set in constants.php,
 * and shown commented out here.
 *
 * Example: downloads/file
 */
define('FILES_URL', 'downloads');

/**
 * File path for storing XPI/JAR files (or any files associated with an add-on).
 * Example: /data/www/app/webroot/files
 */
define('REPO_PATH', '/var/www/files');

/**
 * File path for storing public files to be rsynced for updates
 * If left commented out, files will not be copied there and will use only REPO_PATH
 */
//define('PUBLIC_STAGING_PATH', '');

/**
 * The path to the gnu diff program (or any diff program able to create a unified diff).
 * If left commented out, it will use the xdiff package
 */
//define('DIFF_PATH', '/usr/bin/diff');

/**
 * This is the number of seconds for which repeat downloads will not
 * be counted, since Firefox does multiple gets during a single install process.
*/
define('DL_COUNT_DELAY', '10');

/**
 * Path to directory where detailed logfiles are kept. Files will be created in
 * this directory in the format: {DETAILED_LOG_PATH}/Y-M-D.txt
 */
//define('DETAILED_LOG_PATH', '');

/**
 * Path to directory for misc. AMO storage accessible by all webheads.
 */
define('NETAPP_STORAGE', '');

/**
 * Facebook Configuration
 */
// Whether the Facebook controller is enabled
define('FB_ENABLED', 'false');

// Facebook API keys
define('FB_API_KEY', '');
define('FB_API_SECRET', '');

// Facebook App URL
define('FB_URL', 'http://apps.facebook.com/add-ons');

// Facebook Image site - where images are pulled from
define('FB_IMAGE_SITE', 'https://addons.mozilla.org');

// Facebook Install site - where the add-on install page goes
define('FB_INSTALL_SITE', 'https://addons.mozilla.org');

// Facebook Bounce Percentage - percent of hits to bounce
//define('FB_BOUNCE_PERCENTAGE', 0);

/**
 * Database configuration.
 */

/**
 * DB_USER, DB_PASS, DB_NAME, DB_HOST, DB_PORT
 * This database has read/write capabilities.  Host and port default to localhost and 3306.
 */
define('DB_USER','remora');
define('DB_PASS','remora');
define('DB_NAME','remora');

/**
 * SHADOW_DB_USER, SHADOW_DB_PASS, SHADOW_DB_NAME, SHADOW_DB_HOST, SHADOW_DB_PORT
 * Array of shadow databases that have read-only access.
 * - If left alone, will default to DB_* above.
 * - DB_WEIGHTs must sum to 1. i.e., a weight of 0 will never get hit, a weight
 *   of .50 will get hit half of the time, and a weight of 1 will always get hit.
 * - The array keys need not be numeric and could be used for descriptive purposes
 *   that would appear in the monitor script.
 */
global $shadow_databases;
$shadow_databases = array(
    0 => array(
        'DB_HOST' => '',
        'DB_PORT' => 3306,
        'DB_NAME' => '',
        'DB_USER' => '',
        'DB_PASS' => '',
        'DB_WEIGHT' => 0
    )
);

/**
 * TEST_DB_USER, TEST_DB_PASS, TEST_DB_NAME, TEST_DB_HOST, TEST_DB_PORT
 * The test database.  All fields default to their DB_* counterparts, except
 * for TEST_DB_NAME, which is DB_NAME . "-test".
 */

/**
 * memcache configuration.
 * 
 * The memcache_config array lists all possible memcached servers to use in case the default server does not have the appropriate key.
 */
global $memcache_config;
$memcache_config = array(
    'localhost' => array(
       'port' => '11211',
       'persistent' => true,
       'weight' => '1',
       'timeout' => '1',
       'retry_interval' => 15
    )
);

/**
 * Recaptcha (recaptcha.net) configuration
 */
define('RECAPTCHA_ENABLED', false);
define('RECAPTCHA_PRIVATE_KEY', '...');
define('RECAPTCHA_PUBLIC_KEY', '...');

/**
 * Compatibility Center Versions
 */
define('COMPAT_DEFAULT_VERSION', '3.1');
global $compatibility_versions;
$compatibility_versions = array(
    '3.0', '3.1'
);

?>

Edit config-local.php

vim /var/www/site/app/config/config-local.php

<?php
define('DEBUG', 1);
define('DEV', true);
?>

chown apache:apache /var/www/site/app/config/config-local.php

This is necessary to generate debug message. Without it you get a somewhat disconcerting blankscreen.

Create download directory

mkdir /var/www/downloads
chown -R apache:apache /var/www/downloads

Create repo directories

mkdir /var/www/files
mkdir /var/www/files/temp
mkdir /var/www/files/extracted
chown -R apache:apache /var/www/files

Optional steps

Install php-memcache

yum install php-devel gcc zlib-devel

pecl install memcache
vim /etc/php.ini

You should add "extension=memcache.so" to php.ini

service httpd restart

Install memcached

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install memcached
service memcached start
chkconfig --levels 235 httpd on


Test activities.sugarlabs.org

Open activities.sugarlabs.org in firefox.
If you followed #Auto mode section use

login admin@sugarlabs.org
password test

To run tests open activities.sugarlabs.org/tests?case=installation.test.php in firefox.

TODO

  • Fix search
  • Fix downloads
  • Lots of testing, debugging and fixing
  • Upstream all patches that can make easier future rebases (and have a chance of being accepted)
  • Translate our new strings
  • Change the design accordingly to the Sugar image