summaryrefslogtreecommitdiff
path: root/INSTALL
blob: 8f54f716c4d719aabf710ef7b883478a5d3cc4f2 (plain)
  1. LedgerSMB 1.3 (svn trunk) INSTALL
  2. =================================
  3. This document aims to provide a detailed step by step process to configure a
  4. working instance of LedgerSMB 1.3 from subversion repository or pre-alpha
  5. release tarball.
  6. Subsitute your own values for file paths and definitions shown in ALL_CAPS.
  7. Install LedgerSMB 1.3 Source
  8. ------------------------------------
  9. LedgerSMB 1.3 is still in pre-alpha, with no tarball release files. Check out
  10. LedgerSMB 1.3 from svn trunk:
  11. $ svn co https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk /path/to/ledgersmb13
  12. Change working directory to WORKING_DIR:
  13. ----------------------------------------
  14. WORKING_DIR is the location where you have manually installed the LedgerSMB 1.3
  15. source or checkout. LedgerSMB 1.3 in pre-alpha form is not currently packaged
  16. for any distribution.
  17. $ cd /path/to/ledgersmb13/
  18. /path/to/ledgersmb13 $
  19. All commands from this point forward are executed from WORKING_DIR unless
  20. otherwise noted.
  21. Automating Installation
  22. -----------------------
  23. You can extract the commands in this document with: $ grep -e '^\$' INSTALL
  24. This provides a decent approximation of what would be required for a scripted
  25. install as of this writing.
  26. Apache Configuration
  27. ====================
  28. LedgerSMB uses Apache-2.x, with mod_rewrite.
  29. Create up an Apache conf file for the WORKING_DIR location
  30. ----------------------------------------------------------
  31. Configure ledgersmb-httpd.conf for apache, subsituting WORKING_DIR with the
  32. absolute path of your LedgerSMB installation (e.g. /path/to/ledgersmb13):
  33. The following sed command applies the repetitive substitution automatically.
  34. $ cat ledgersmb-httpd.conf | sed "s|WORKING_DIR|$(pwd)|" > ledgersmb-httpd-13.conf
  35. You can also apply the substitution manually in your preferred text editor.
  36. Install the Apache conf file
  37. ----------------------------
  38. Move the apache conf file ledgersmb-httpd-13.conf to a location where it will be
  39. picked up on apache restart:
  40. $ sudo mv ledgersmb-httpd-13.conf /etc/apache2/app/ledgersmb13.conf
  41. Restart apache:
  42. $ sudo /etc/init.d/apache2 restart
  43. * Stopping apache2 ... [ ok ]
  44. * Starting apache2 ... [ ok ]
  45. Verify that RewriteRule is working
  46. ----------------------------------
  47. LedgerSMB 1.3 depends on mod_rewrite's ReWriteRule. Make sure that your Apache
  48. has module or built-in support for mod_rewrite. You can test this if you are
  49. unsure. Use an .htaccess file to check that mod_rewrite is working and that our
  50. directory alias has been loaded by apache:
  51. $ echo -e 'RewriteEngine on\nRewriteRule ^(.*)$ http://www.google.com [R]' > /path/to/ledgersmb13/.htaccess
  52. $ wget -qO /dev/stdout http://localhost/ledgersmb | grep -c '<title>Google</title>'
  53. 1
  54. If you saw the grep output "1" above, RewriteRule is working. Remove your
  55. temporary .htaccess file:
  56. $ rm .htaccess
  57. Apache must be able to read and write WORKING_DIR
  58. -------------------------------------------------
  59. Make sure the WORKING_DIR directory is read-writable by user:group
  60. apache:apache, or as appropriate for your distribution's Apache conventions.
  61. Check And Satisfy Perl Dependencies
  62. ===================================
  63. LedgerSMB depends on Perl-5.8, and several CPAN packages, which may or may not
  64. be available as system packages for your linux distribution:
  65. $ perl -v | grep v5.
  66. This is perl, v5.8.8 built for i686-linux
  67. Run Makefile.PL to check for LedgerSMB's Perl dependencies. The output should be
  68. similar to the following:
  69. $ perl Makefile.PL
  70. include /path/to/ledgersmb13/inc/Module/Install.pm
  71. include inc/Module/Install/Metadata.pm
  72. include inc/Module/Install/Base.pm
  73. include inc/Module/Install/AutoInstall.pm
  74. include inc/Module/Install/Include.pm
  75. include inc/Module/AutoInstall.pm
  76. *** Module::AutoInstall version 1.03
  77. *** Checking for Perl dependencies...
  78. [Core Features]
  79. - Test::More ...loaded. (0.8)
  80. - Test::Trap ...loaded. (0.0.23)
  81. - Test::Exception ...loaded. (0.27)
  82. - Data::Dumper ...loaded. (2.121)
  83. - Locale::Maketext ...loaded. (1.13)
  84. - Locale::Maketext::Lexicon ...loaded. (0.64 >= 0.56)
  85. - DBI ...loaded. (1.601 >= 1.00)
  86. - MIME::Base64 ...loaded. (3.07)
  87. - Digest::MD5 ...loaded. (2.36)
  88. - HTML::Entities ...loaded. (1.35)
  89. - DBD::Pg ...loaded. (1.49)
  90. - Math::BigFloat ...loaded. (1.51)
  91. - IO::File ...loaded. (1.13)
  92. - Encode ...loaded. (2.12)
  93. - Locale::Country ...loaded. (2.07)
  94. - Locale::Language ...loaded. (2.07)
  95. - Time::Local ...loaded. (1.18)
  96. - Cwd ...loaded. (3.2701)
  97. - Config::Std ...loaded. (0.0.4)
  98. - MIME::Lite ...loaded. (3.01)
  99. - Template ...loaded. (2.19 >= 2.14)
  100. - Error ...loaded. (0.17012)
  101. - CGI::Simple ...loaded. (1.0)
  102. [POS module credit card processing support]
  103. - Net::TCLink ...loaded. (3.4)
  104. [Experimental scripting engine]
  105. - Parse::RecDescent ...loaded. (1.94)
  106. [Developer tool dependencies]
  107. - Getopt::Long ...loaded. (2.35)
  108. - FileHandle ...loaded. (2.01)
  109. [PDF and Postscript output]
  110. - Template::Latex ...loaded. (2.17)
  111. [OpenOffice.org output]
  112. - XML::Twig ...loaded. (3.32)
  113. - OpenOffice::OODoc ...loaded. (2.035)
  114. [Excel output]
  115. - Excel::Template::Plus ...loaded. (0.03)
  116. *** Module::AutoInstall configuration finished.
  117. include inc/Module/Install/Makefile.pm
  118. include inc/Module/Install/WriteAll.pm
  119. Writing META.yml
  120. include inc/Module/Install/Win32.pm
  121. include inc/Module/Install/Can.pm
  122. include inc/Module/Install/Fetch.pm
  123. include inc/Module/Install/Build.pm
  124. Writing Makefile for LedgerSMB
  125. Use your distribution's CPAN or packaging tools to satisfy the dependencies
  126. shown above.
  127. =========================
  128. PostgreSQL Configuration
  129. =========================
  130. LedgerSMB 1.3 is tightly integrated with PostgreSQL. In the current pre-alpha
  131. state, it is necessary to run several PostgreSQL commands and SQL statements
  132. exactly as shown below. Automated installers will ease this process in future
  133. releases.
  134. TODO: Securing PostgreSQL with LedgerSMB
  135. ========================================
  136. An experienced PostgreSQL expert should author a section which describes how to
  137. properly modify the typical default pg_hba.conf etc., such that LedgerSMB 1.3
  138. works, but without opening up the database to unneccessary network access.
  139. Installing PostgreSQL Contrib Function Libraries (Not Optional)
  140. ===============================================================
  141. LedgerSMB 1.3 depends on several function libraries distributed with PostgreSQL,
  142. but typically not installed by default in most distributions.
  143. Identify the system package containing the files tsearch2.sql, tablefunc.sql,
  144. and pg_trgm.sql. Install that package, and locate the files on the filesystem.
  145. You only need to install these function libraries once per postgresql cluster.
  146. For the remainder of this INSTALL procedure, you will need to become user
  147. postgres, or have the ability to log in to psql as your current user, or issue
  148. the commands with: sudo -u postgres [cmd].
  149. Install Tsearch2 Full Text indexing engine for PostgreSQL
  150. ---------------------------------------------------------
  151. $ psql -U postgres -d template1 -f /usr/share/postgresql-8.3/contrib/tsearch2.sql
  152. Install tablefunc.sql for PostgreSQL
  153. ------------------------------------
  154. $ psql -U postgres -d template1 -f /usr/share/postgresql-8.3/contrib/tablefunc.sql
  155. Install pg_trgm.sql for PostgreSQL
  156. ----------------------------------
  157. $ psql -U postgres -d template1 -f /usr/share/postgresql-8.3/contrib/pg_trgm.sql
  158. TODO: Test install of tsearch2, tablefunc, pg_trgm
  159. --------------------------------------------------
  160. Create test functions for user to verify proper contrib library
  161. loading. Instruct the user how to run them.
  162. Configure a LedgerSMB PostgreSQL role
  163. =====================================
  164. Create the ledgersmb PostgreSQL role (optional):
  165. $ createuser --no-superuser --createdb --no-createrole -U postgres --pwprompt --encrypted ledgersmb
  166. Make a note of the password you enter, we'll refer to it as LSMB_PASSWORD.
  167. Configure a LedgerSMB Company Database
  168. ======================================
  169. Create a LedgerSMB company database. The user and configuration information
  170. are stored alongside the accounting data as of this writing:
  171. $ createdb -U postgres -O ledgersmb mycompany
  172. Install the plpgsql procedural language to the company database:
  173. $ createlang plpgsql mycompany
  174. Apply the SQL statements in /path/to/ledgersmb13/sql/Pg-database.sql to
  175. the company database:
  176. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/Pg-database.sql
  177. Apply the in-development SQL statements in the files WORKING_DIR/sql/modules/ to
  178. the company database, in exactly the following order:
  179. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Drafts.sql
  180. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/chart.sql
  181. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Account.sql
  182. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Session.sql
  183. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Business_type.sql
  184. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Location.sql
  185. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Company.sql
  186. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Customer.sql
  187. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Date.sql
  188. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Defaults.sql
  189. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Settings.sql
  190. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Employee.sql
  191. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Entity.sql
  192. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Payment.sql
  193. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Person.sql
  194. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Report.sql
  195. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/sql/modules/Voucher.sql
  196. At the time of this writing, the following files are in an earlier state of
  197. development and not ready to be loaded:
  198. admin.sql
  199. security.sql
  200. Reconciliaton.sql
  201. Generate A Custom Roles SQL Statement File
  202. ------------------------------------------
  203. Preprocess the sql/modules/Roles.sql file with sed, generating a custom SQL file
  204. in WORKING_DIR:
  205. $ sed -e 's/<?lsmb dbname ?>/mycompany/g' /path/to/ledgersmb13/sql/modules/Roles.sql > /path/to/ledgersmb13/mycompany_roles.sql
  206. Apply the SQL statements in the sed-generated file mycompany_roles.sql to the
  207. company database:
  208. $ psql -U postgres -d mycompany -f /path/to/ledgersmb13/mycompany_roles.sql
  209. Create A PostgreSQL Role
  210. ------------------------
  211. Create a postgresql role which you will use to log into the company
  212. database:
  213. $ createuser --no-superuser --createdb --no-createrole -U postgres --pwprompt --encrypted myuser
  214. Note the password entered at the prompt as MYUSER_PASSWORD. You will use this to login to the
  215. LedgerSMB 1.3 instance.
  216. Create A Company User
  217. =====================
  218. The following section creates a company user 'myuser' and configures that user
  219. for use with 'mycompany'.
  220. Insert myuser Entity
  221. --------------------
  222. Using the psql console, insert myuser to the entity table.
  223. $ psql -U postgres -d mycompany -t -c "INSERT INTO entity (name, entity_class, created) VALUES ('myuser', 3, NOW()) RETURNING name, entity_class, created;"
  224. myuser | 3 | 2008-08-08
  225. INSERT 0 1
  226. Insert myuser Persion
  227. ---------------------
  228. Insert the myuser entity into the person table:
  229. $ psql -U postgres -d mycompany -t -c "INSERT INTO person (entity_id, first_name, last_name, created) VALUES (2, 'Firstname', 'Lastname', NOW()) RETURNING entity_id, first_name, last_name, created;"
  230. 2 | Firstname | Lastname | 2008-08-08
  231. INSERT 0 1
  232. Insert myuser Employee
  233. ----------------------
  234. Insert the myuser person into the entity_employee table:
  235. $ psql -U postgres -d mycompany -t -c "INSERT INTO entity_employee (person_id, entity_id, startdate, role) VALUES (1, 2, NOW(), 'myuser') RETURNING person_id, entity_id, startdate, role;"
  236. 1 | 2 | 2008-08-08 | myuser
  237. INSERT 0 1
  238. Insert myuser User
  239. ------------------
  240. Insert the myuser username and its entity id into the users table:
  241. $ psql -U postgres -d mycompany -t -c "INSERT INTO users (username, entity_id) VALUES ('myuser', 2) RETURNING username, entity_id;"
  242. myuser | 2
  243. INSERT 0 1
  244. Insert myuser Preferences
  245. -------------------------
  246. Insert the myuser's person_id into user_preferences:
  247. $ psql -U postgres -d mycompany -t -c "INSERT INTO user_preference (id) VALUES (1) RETURNING id;"
  248. 1
  249. Temporary Workaround: Grant All Roles To myuser
  250. -----------------------------------------------
  251. As of this writing, the following workaround is recommended to apply all
  252. LedgerSMB 1.3 roles (i.e. rolname LIKE 'lsmb%') to a company user. Create the
  253. following function:
  254. $ psql -U postgres -d mycompany -t -c "CREATE OR REPLACE FUNCTION grant_all_roles(in_login varchar) RETURNS INT as \$\$ DECLARE role_info RECORD; BEGIN FOR role_info IN select * from pg_roles WHERE rolname LIKE 'lsmb%' LOOP EXECUTE 'GRANT ' || role_info.rolname || ' TO ' || in_login; END LOOP; RETURN 1; END; \$\$ language plpgsql;"
  255. CREATE FUNCTION
  256. And execute the function for myuser:
  257. $ psql -U postgres -d mycompany -t -c "SELECT grant_all_roles('myuser');"
  258. Login to LedgerSMB 1.3 Instance
  259. ===============================
  260. It should now be possible to log into your LedgerSMB 1.3 instance at:
  261. http://localhost/ledgersmb
  262. With cookies enabled for localhost.
  263. Name: myuser
  264. Password: MYUSER_PASSWORD
  265. Company: mycompany
  266. Workarounds
  267. ===========
  268. In its pre-alpha state, when accessing certain parts of the LedgerSMB 1.3 system
  269. you may encounter permission errors. For example:
  270. DBD::Pg::st execute failed: ERROR: permission denied for relation warehouse
  271. Error!
  272. SELECT id, description
  273. FROM warehouse
  274. ORDER BY 2
  275. ERROR: permission denied for relation warehouse
  276. It is possible to grant the permissions directly, until a bug is filed, and the
  277. code and this INSTALL document is updated to fix the bug. As of this writing,
  278. the following SQL statements help avoid these types of errors:
  279. $ psql -U postgres -d mycompany -t -c "GRANT SELECT ON warehouse TO public;"
  280. GRANT
  281. $ psql -U postgres -d mycompany -t -c "GRANT SELECT ON translation TO public;"
  282. GRANT
  283. $ psql -U postgres -d mycompany -t -c "GRANT SELECT ON pricegroup TO public;"
  284. GRANT
  285. $ psql -U postgres -d mycompany -t -c "GRANT SELECT ON taxmodule TO public;"
  286. GRANT
  287. $ psql -U postgres -d mycompany -t -c "GRANT SELECT ON sic TO public;"
  288. GRANT
  289. How-To Section
  290. ==============
  291. Q: How do I remove the 90+ roles for mycompany created by the INSTALL process?
  292. A: First, since most objects in the mycompany database depend on these roles,
  293. you must drop the mycompany database first, obviously with loss of data.
  294. $ dropdb -U postgres mycompany
  295. After that, you must issue the droprole command for each rolname in the query
  296. embedded in the following command:
  297. $ for role in `psql -U postgres -t -c "SELECT rolname FROM pg_roles WHERE rolname LIKE 'lsmb_mycompany%';"`; do dropuser -U postgres $role; done
  298. Q: The Admin UI isn't functional yet, how to I set my preferred CSS stylesheet?
  299. A: You might find another CSS stylesheet to your liking, but there is currently
  300. no UI to set it. Run the following command. If you know your users.id, you can
  301. modify the query:
  302. $ psql -U postgres -d mycompany -c "UPDATE user_preference SET stylesheet='ledgersmb-smallgray.css';"
  303. UPDATE 1