Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:dataserver_setup [2011/07/15 04:00] – simonth | dev:dataserver_setup [2014/09/18 03:45] (current) – Delete uselessly ancient unofficial instructions, which shouldn't be hosted here anyway dstillman | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | == This installation was tested on Ubuntu 11.04 with SVN revision 9803. == | ||
- | |||
- | \\ | ||
- | __Before starting, here are the packages to setup on your machine (we suppose you have an apache server running and know how to make basic configuration changes to it):__ | ||
- | |||
- | * PHP (php5) | ||
- | * PHP modules (php5-mysql, | ||
- | * Apache module: mod_rewrite | ||
- | * MySQL with root access (mysql-server, | ||
- | * MongoDB (http:// | ||
- | * Memcached (same as MongoDB but don't add " | ||
- | * Ability to configure /etc/hosts | ||
- | * Subversion client | ||
- | |||
- | Now, we can begin. | ||
- | |||
- | ===== Step 1 ===== | ||
- | Download Zotero dataserver sources (here: https:// | ||
- | Use your subversion client to pull down the sources from Zotero' | ||
- | These files can be anywhere but this guide will assume they are located in / | ||
- | You can use the following command-line: | ||
- | < | ||
- | $ sudo svn co https:// | ||
- | </ | ||
- | |||
- | |||
- | ===== Step 2 ===== | ||
- | Set up an apache VirtualHost for the dataserver.\\ | ||
- | Use this code: | ||
- | < | ||
- | NameVirtualHost *:443 | ||
- | < | ||
- | DocumentRoot / | ||
- | SSLEngine on | ||
- | SSLCertificateFile / | ||
- | SSLCertificateKeyFile / | ||
- | < | ||
- | Options FollowSymLinks MultiViews | ||
- | AllowOverride All | ||
- | Order allow,deny | ||
- | Allow from all | ||
- | </ | ||
- | AllowEncodedSlashes On | ||
- | </ | ||
- | </ | ||
- | |||
- | Save this code as the file " | ||
- | |||
- | NOTE: don't forget to create SSL certificate and SSL key. Like this: | ||
- | < | ||
- | $ sudo mkdir / | ||
- | $ cd / | ||
- | $ sudo openssl req -config / | ||
- | $ sudo openssl rsa -in privkey.pem -out server.key | ||
- | $ sudo openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365 | ||
- | $ sudo openssl x509 -in server.crt -out server.der.crt -outform DER | ||
- | $ sudo cp server.crt / | ||
- | $ sudo cp server.key / | ||
- | $ cd / | ||
- | $ sudo ln -s ../ | ||
- | </ | ||
- | |||
- | |||
- | ===== Step 3 ===== | ||
- | Add an /etc/hosts entry for sync.zotero.org and api.zotero.org to the IP address of the server.\\ | ||
- | Command to edit /etc/hosts: | ||
- | < | ||
- | $ sudo pico / | ||
- | </ | ||
- | |||
- | It should be like this (for example): | ||
- | < | ||
- | 127.0.0.1 localhost | ||
- | |||
- | 192.168.142.21 sync.zotero.org api.zotero.org | ||
- | </ | ||
- | |||
- | Make this for all the machines that will access to the server. | ||
- | |||
- | |||
- | ===== Step 4 ===== | ||
- | Copy the sample config files under / | ||
- | You'll need to edit these two files later (cf. Step 8). | ||
- | |||
- | |||
- | ===== Step 5 ===== | ||
- | Change MySQL time zone. It must be UTC time.\\ | ||
- | So, edit my.cnf file in /etc/mysql/ directory.\\ | ||
- | Add the " | ||
- | < | ||
- | [mysqld] | ||
- | ... | ||
- | ... | ||
- | default-time-zone = ' | ||
- | </ | ||
- | |||
- | Restart MySQL: | ||
- | < | ||
- | $ sudo / | ||
- | </ | ||
- | |||
- | ===== Step 6 ===== | ||
- | Create zotero_cache database (using cache.sql in /misc/ directory).\\ | ||
- | Create zotero_www_test and zotero_www databases.\\ | ||
- | Create a users table for zotero_www_test and zotero_www (not for zotero_cache): | ||
- | < | ||
- | CREATE TABLE `users` ( | ||
- | `userID` | ||
- | `username` | ||
- | `slug` | ||
- | `password` | ||
- | `email` | ||
- | `openid` | ||
- | `role` | ||
- | `resetValidationKey` char(40) | ||
- | `resetValidationExp` int NULL, | ||
- | `emailValidationKey` char(10) | ||
- | `emailValidated` | ||
- | `hasImage` | ||
- | `lastUpdated` | ||
- | `dateRegistered` | ||
- | PRIMARY KEY (`userID`), | ||
- | UNIQUE KEY (`username`), | ||
- | UNIQUE KEY (`slug`), | ||
- | UNIQUE KEY (`email`), | ||
- | UNIQUE KEY (`resetValidationKey`) | ||
- | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; | ||
- | </ | ||
- | |||
- | |||
- | ===== Step 7 ===== | ||
- | Give write access to the /tmp/ directory to apache. | ||
- | |||
- | |||
- | ===== Step 8 ===== | ||
- | Edit config.inc.php, | ||
- | * **config.inc.php**: | ||
- | < | ||
- | <? | ||
- | class Z_CONFIG { | ||
- | public static $API_ENABLED = true; | ||
- | public static $SYNC_ENABLED = true; | ||
- | public static $PROCESSORS_ENABLED = true; | ||
- | public static $MAINTENANCE_MESSAGE = ' | ||
- | |||
- | public static $TESTING_SITE = true; | ||
- | public static $DEV_SITE = true; | ||
- | |||
- | public static $BASE_URI = ''; | ||
- | |||
- | public static $AUTH_SALT = ''; | ||
- | public static $API_SUPER_USERNAME = ''; | ||
- | public static $API_SUPER_PASSWORD = ''; | ||
- | |||
- | public static $API_BASE_URI = ''; | ||
- | public static $SYNC_DOMAIN = ' | ||
- | |||
- | public static $S3_BUCKET = ''; | ||
- | public static $S3_ACCESS_KEY = ''; | ||
- | public static $S3_SECRET_KEY = ''; | ||
- | |||
- | public static $MEMCACHED_ENABLED = false; | ||
- | public static $MEMCACHED_SERVERS = array( | ||
- | ' | ||
- | ); | ||
- | |||
- | public static $MONGO_SERVERS = array( | ||
- | ' | ||
- | ); | ||
- | public static $MONGO_DB = " | ||
- | public static $MONGO_SAFE_NUM = 2; | ||
- | |||
- | public static $TRANSLATE_SERVERS = array( | ||
- | " | ||
- | ); | ||
- | |||
- | public static $CITE_SERVERS = array( | ||
- | " | ||
- | ); | ||
- | |||
- | public static $LOG_TO_SCRIBE = false; | ||
- | public static $LOG_ADDRESS = ''; | ||
- | public static $LOG_PORT = 1463; | ||
- | public static $LOG_TIMEZONE = ' | ||
- | public static $LOG_TARGET_DEFAULT = ' | ||
- | |||
- | public static $PROCESSOR_PORT_DOWNLOAD = 3455; | ||
- | public static $PROCESSOR_PORT_UPLOAD = 3456; | ||
- | public static $PROCESSOR_PORT_ERROR = 3457; | ||
- | public static $PROCESSOR_PORT_INDEX = 3458; | ||
- | |||
- | public static $PROCESSOR_LOG_TARGET_DOWNLOAD = ' | ||
- | public static $PROCESSOR_LOG_TARGET_UPLOAD = ' | ||
- | public static $PROCESSOR_LOG_TARGET_ERROR = ' | ||
- | public static $PROCESSOR_LOG_TARGET_INDEX = ' | ||
- | |||
- | public static $SYNC_DOWNLOAD_SMALLEST_FIRST = false; | ||
- | public static $SYNC_UPLOAD_SMALLEST_FIRST = false; | ||
- | |||
- | // Set some things manually for running via command line | ||
- | public static $CLI_PHP_PATH = '/ | ||
- | public static $CLI_DOCUMENT_ROOT = "/ | ||
- | |||
- | public static $SYNC_ERROR_PATH = '/ | ||
- | public static $API_ERROR_PATH = '/ | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | |||
- | * **dbconnect.inc.php**: | ||
- | < | ||
- | <? | ||
- | function Zotero_dbConnectAuth($db) { | ||
- | if ($db == ' | ||
- | $host = ' | ||
- | $port = 3306; | ||
- | $db = ' | ||
- | $user = ' | ||
- | $pass = ' | ||
- | } | ||
- | |||
- | else if ($db == ' | ||
- | $host = ' | ||
- | $port = 3306; | ||
- | $db = ' | ||
- | $user = ' | ||
- | $pass = ' | ||
- | } | ||
- | |||
- | else if ($db == ' | ||
- | $host = ' | ||
- | $port = 3306; | ||
- | $db = ' | ||
- | $user = ' | ||
- | $pass = ' | ||
- | } | ||
- | |||
- | else if ($db == ' | ||
- | $host = ' | ||
- | $port = 3306; | ||
- | $db = ' | ||
- | $user = ' | ||
- | $pass = ' | ||
- | } | ||
- | |||
- | else if ($db == ' | ||
- | $host = ' | ||
- | $port = 3306; | ||
- | $db = ' | ||
- | $user = ' | ||
- | $pass = ' | ||
- | } | ||
- | |||
- | else if ($db == ' | ||
- | $host = ' | ||
- | $port = 3306; | ||
- | $db = ' | ||
- | $user = ' | ||
- | $pass = ' | ||
- | } | ||
- | |||
- | else { | ||
- | throw new Exception(" | ||
- | } | ||
- | return array(' | ||
- | } | ||
- | ?> | ||
- | </ | ||
- | |||
- | * **Sync.inc.php** (in /model/ directory): | ||
- | |||
- | Put the following lines in comment (or delete them): | ||
- | < | ||
- | if (!Zotero_Libraries:: | ||
- | throw new Exception(" | ||
- | } | ||
- | </ | ||
- | |||
- | These are lines 1406 to 1408.\\ | ||
- | |||
- | A solution to this has been suggested in the mailing list (see http:// | ||
- | |||
- | |||
- | ===== Step 9 ===== | ||
- | Loading https:// | ||
- | /!\ You must accept SSL certificates before (on https:// | ||
- | |||
- | |||
- | ===== Step 10 ===== | ||
- | Create or edit .my.cnf in your home directory (/ | ||
- | < | ||
- | [client] | ||
- | user=root | ||
- | password=root_password | ||
- | </ | ||
- | |||
- | |||
- | ===== Step 11 ===== | ||
- | Change directory to /misc/ directory. | ||
- | |||
- | |||
- | ===== Step 12 ===== | ||
- | Edit test_reset and test_setup.\\ | ||
- | * In test_reset AND test_setup: replace all " | ||
- | * In test_reset: replace | ||
- | < | ||
- | # Set up sample users | ||
- | echo " | ||
- | echo " | ||
- | echo " | ||
- | </ | ||
- | |||
- | by | ||
- | |||
- | < | ||
- | # Set up sample user in zotero_www_test | ||
- | echo " | ||
- | echo " | ||
- | |||
- | # Set up sample user in zotero_www | ||
- | echo " | ||
- | echo " | ||
- | </ | ||
- | |||
- | |||
- | ===== Step 13 ===== | ||
- | Launch the command: | ||
- | < | ||
- | $ sudo ./ | ||
- | </ | ||
- | |||
- | Normally, there are few little errors but nothing fatal. I didn't pay attention to it. | ||
- | |||
- | |||
- | ===== Step 14 ===== | ||
- | Launch daemons.\\ | ||
- | There are 4 daemons, each in its own directory under the processor directory. Fire up for shells and run each independently in the foreground! | ||
- | < | ||
- | $ cd processor/ | ||
- | $ php daemon.php | ||
- | $ cd processor/ | ||
- | $ php daemon.php | ||
- | $ cd processor/ | ||
- | $ php daemon.php | ||
- | $ cd processor/ | ||
- | $ php daemon.php | ||
- | </ | ||
- | |||
- | In all cases you should see the output similar to this (the daemon name will vary): | ||
- | < | ||
- | Starting sync download processor daemon | ||
- | 0 processors, 0 queued processes | ||
- | </ | ||
- | |||
- | |||
- | ===== Step 15 ===== | ||
- | You can try to sync Zotero with login=testuser and password=testuser.\\ | ||
- | Normally, it works! | ||
- | \\ \\ | ||
- | |||
- | ===== Miscellaneous ===== | ||
- | |||
- | ==== Add new user ==== | ||
- | |||
- | You must add new entries in zotero_www (or zotero_www_test if in test mode). | ||
- | |||
- | * Necessary fields should be userID, username, slug, password. | ||
- | * Password entries are generated by taking a sha1 hash of the user’s password. | ||
- | * Slugs are generated by taking the username and trimming whitespace, lowercasing, | ||
- | |||
- | ==== Create group ==== | ||
- | |||
- | As shown in ‘test_reset’ file: | ||
- | |||
- | TODO explain values | ||
- | |||
- | < | ||
- | INSERT INTO libraries VALUES (3, ' | ||
- | INSERT INTO groups VALUES (1, 3, 'Test Group', | ||
- | INSERT INTO groupUsers VALUES (1, 1, ' | ||
- | INSERT INTO shardLibraries VALUES (3, ' | ||
- | </ | ||
- | |||
- | ==== Custom Zotero ==== | ||
- | |||
- | TODO explain how edit zotero.jar | ||
- | |||
- | If you want to use your own domain you need to edit the plugin. | ||
- | Edit zotero.js and change SYNC_URL and API_URL with your domain. | ||
- | |||
- | < | ||
- | const ZOTERO_CONFIG = { | ||
- | GUID: ' | ||
- | DB_REBUILD: false, // erase DB and recreate from schema | ||
- | REPOSITORY_URL: | ||
- | REPOSITORY_CHECK_INTERVAL: | ||
- | REPOSITORY_RETRY_INTERVAL: | ||
- | BASE_URI: ' | ||
- | WWW_BASE_URL: | ||
- | SYNC_URL: ' | ||
- | API_URL: ' | ||
- | }; | ||
- | </ | ||
- | |||
- | ===== Untested / Not working / Todo ===== | ||
- | |||
- | ==== Untested ==== | ||
- | * Webdav to use files attachment. | ||
- | * API: explain how to use it or configure it. | ||
- | |||
- | ==== Not working ==== | ||
- | * Change user privileges in groups only work if the user performs a restore from the server | ||
- | * Sync attachment files in My Library using Zotero server (i suppose you need Amazon S3) | ||
- | * Sync attachment files in group using Zotero server (i suppose you need Amazon S3) | ||
- | |||
- | ==== Todo ==== | ||
- | * Create SQL script to install database in one step | ||
- | * Create interface to add/manage users and groups | ||
- | * Test with webdav to use files attachment | ||