Project

General

Profile

Support #883

Updated by Daniel Curtis about 7 years ago

This is a guide for setting up the Open-Source-Billing web app on FreeBSD 10. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 </pre> 

 * Install a few dependencies: 
 <pre> 
 pkg install git sudo bash autoconf automake libtool bison readline sqlite3 gdbm gmake v8 ImageMagick-nox11 wkhtmltopdf ruby rubygem-bundler 
 </pre> 

 * Add the osb user 
 <pre> 
 pw add user -n osb -s /sbin/nologin -c "Open Source Billing" 
 </pre>  

 h2. Install MariaDB server 

 * Start by installing the mariadb100-server and mariadb100-client packages: 
 <pre> 
 pkg install mariadb100-{server,client} 
 </pre> 

 * Copy a base MariaDB configuration to use: 
 <pre> 
 cp /usr/local/share/mysql/my-small.cnf /var/db/mysql/my.cnf 
 </pre> 

 * Edit the mariadb config to change the max packet size: 
 <pre> 
 vi /var/db/mysql/my.cnf 
 </pre> 
 #* and modify @max_allowed_packet@ to 32M 
 <pre> 
 max_allowed_packet = 32M 
 </pre> 

 * Enable and start MariaDB 
 <pre> 
 echo 'mysql_enable="YES"' >> /etc/rc.conf 
 service mysql-server start 
 </pre> 

 * Prepare the database for use by running the secure installation: 
 <pre> 
 mysql_secure_installation 
 </pre> 
 #* *NOTE*: +Choose a strong root password+ and answer +yes+ to all questions. 

 h3. Create MariaDB Databases and Users 

 * Login to MariaDB and create appropriate databases and users. 
 <pre> 
 mysql -u root -p 
 </pre> 
 #* and run the following SQL queries to create the *osbdb* database and *osbuser* user: 
 <pre> 
 CREATE DATABASE osbdb CHARACTER SET utf8; 

 CREATE USER 'osbuser'@'localhost' IDENTIFIED BY 'SuperSecretPassword'; 

 GRANT ALL PRIVILEGES ON osbdb.* TO 'osbuser'@'localhost'; 

 FLUSH PRIVILEGES; 

 quit 
 </pre> 

 h2. Install RVM 

 * Change the default shell to bash: 
 <pre> 
 chsh 
 </pre> 

 * Switch to the temp directory: 
 <pre> 
 cd /tmp 
 </pre> 

 * Download the RVM installer script: 
 <pre> 
 fetch https://get.rvm.io -o installer.sh 
 </pre> 

 * Install the latest stable release of RVM: 
 <pre> 
 bash installer.sh stable 
 </pre> 

 * Setup the required ruby version: 
 <pre> 
 rvm install 2.0.0 
 </pre> 

 h2. Install Open-Source-Billing 

 * Add the osb user 
 <pre> 
 pw add user -m -n osb -s /usr/local/bin/bash -G rvm -c "Open Source Billing" 
 </pre> 

 * Make the web directory: 
 <pre> 
 mkdir -p /usr/local/www 
 cd /usr/local/www 
 </pre> 

 * Clone the open-source-billing repo from GitHub: 
 <pre> 
 git clone https://github.com/vteams/open-source-billing osb 
 cd osb 
 </pre> 

 * Change the permissions to osb: 
 <pre> 
 chown -R osb /usr/local/www/osb 
 </pre> 

 * Switch to the osb user and set the default ruby version: 
 <pre> 
 su - osb 
 cd /usr/local/www/osb 
 rvm use 2.0.0 --default 
 </pre> 

 * Install bundler: 
 <pre> 
 gem install bundler 
 </pre> 

 * Switch to the osb directory and setup bundler to use the system version of v8: 
 <pre> 
 bundle config build.libv8 --with-system-v8 
 </pre> 

 * Install the required gems: 
 <pre> 
 sudo -u osb bundle install 
 </pre> 

 * Copy the example open-source-billing config file: 
 <pre> 
 cp config/config.yml.copy config/config.yml 
 </pre> 

 * Copy the example database config: 
 <pre> 
 cp config/database.yml.backup config/database.yml.sample to config/database.yml 
 </pre> 
 #* And update the config app host location: 
 <pre> 
 production: 
   app_host: '192.168.1.100' 
   app_protocol: http 
 </pre> 

 * Edit the database config: 
 <pre> 
 vi config/database.yml 
 </pre> 
 #* And and set the your mysql username/password 
 <pre> 
 production: 
   adapter: mysql2 
   encoding: utf8 
   reconnect: false 
   database: osbdb 
   pool: 5 
   username: osbuser 
   password: SuperSecretPassword 
   host: localhost 
 </pre> 

 * Create the database tables needed to run: 
 <pre> 
 RAILS_ENV=production rake db:create 
 RAILS_ENV=production rake db:migrate 
 </pre> 

 h2. Resources 

 * https://github.com/vteams/open-source-billing

Back