BillRun DB is mainly based on clustered MongoDB to allow for data growth, The BillRun application server will
be on the same server as the MongoDB Router service (mongos) to maximize availability of the application.
$ rpm --import https://www.mongodb.org/static/pgp/server-3.6.asc
$ echo '[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
' | sudo tee /etc/yum.repos.d/mongodb-org-3.6.repo
$ sudo yum install mongodb-org mongodb-org-server
go to : http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/ and follow the instructions.
And we suggest to follow the linux production notes and configure the kernel as specified in :
https://docs.mongodb.com/manual/administration/production-notes/#mongodb-on-linux
Full cluster setup is beyond the scope of this document however MongoDB has a very descriptive cluster
setup documentation at : https://docs.mongodb.com/manual/tutorial/deploy-shard-cluster
Installation of each mongo instance on each server of the cluster (mongos / config / DB nodes) is the same as above in Installing a MongoDB service under CentOS on a host
First without authentication create db admin role that can manage databases. Under mongodb console run the next commands:
use admin
db.createUser({"user" : "admin", "pwd" : "*******", "roles":["userAdminAnyDatabase", "readWriteAnyDatabase", "dbAdminAnyDatabase", "clusterAdmin"]})
$ mongo admin -u root -p
> use billing
> db.createUser({"user" : "billrun", "pwd" : "*******", "roles" : [ "readWrite", "dbAdmin", "userAdmin" ]})
> db.createUser({"user" : "reading", "pwd" : "*******", "roles" : [ "read" ]})
Also if you would like to create a local development cluster for dev and test machines the BillRun code contains a script to construct a local development cluster at :
$BILLRUN_DIR/scripts/mongodb_localhost_cluster.sh
This Script will create 3 mongod instances and one mongos instance in the localhost. Their ports will be as follows:
Usage example :
$BILLRUN_DIR/scripts/mongodb_localhost_cluster.sh -d <local cluster db root directory>
$ yum install epel-release
$ yum install php71-php-pear php71-php-pecl-mongo php71u-cli php71u-mysqlnd php71-php-devel
$ yum --enablerepo=remi install php71-php-curl php71u-json php71u-xml php71u-bcmath
$ sudo yum install gcc make pcre-devel git openssl-devel
$ sudo pecl install yaf-2.3.5 mongo stomp # no need for SASL on the mongo driver installation
$ echo "extension=yaf.so" | sudo tee /etc/php.d/yaf.ini
$ echo "extension=mongo.so" | sudo tee /etc/php.d/mongo.ini
$ sudo yum install httpd24 httpd24-tools php71 php71-common php71-pear php71-devel php71-bcmath php71 php71-curl php71-xml php71-pdo php71-mysql
$ sudo yum install gcc make pcre-devel git openssl-devel
$ sudo pecl install yaf mongo stomp
$ echo "extension=yaf.so" | sudo tee /etc/php-7.1.d/yaf.ini
$ echo "extension=mongo.so" | sudo tee /etc/php-7.1.d/mongo.ini
$ sudo yum install httpd
$ export BILLRUN_DIR=<Application Directory full path>
$ echo "#BillRun configuration
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName billrun
DocumentRoot $BILLRUN_DIR/public
SetEnv APPLICATION_ENV test # Please put the correct environment manually
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory $BILLRUN_DIR/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog \${APACHE_LOG_DIR}/access.log combined
<IfModule mod_php7.c>
php_admin_value upload_max_filesize 2000M
</IfModule>
</VirtualHost>" | sudo tee -a <Main Configuration Directory>/httpd/conf.d/httpd-vhosts.conf
Edit the <Main Configuration Directory>/httpd/conf/httpd.conf file and include both deflate module and expires module also make sure rewrite module is active, so at the end you’ll have In the Configuration file the following:
#LoadModule charset_lite_module modules/mod_charset_lite.so
LoadModule deflate_module modules/mod_deflate.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule rewrite_module modules/mod_rewrite.so
Restart the apache server to load the updated configuration :
$ sudo service httpd restart
$ sudo yum install nginx php71-fpm
$ export BILLRUN_DIR=<Application Directory full path> # normally at /var/www/billrun
$ export BILLRUN_HOSTNAME=<assigned host name>
$ echo "
server {
index index.php index.html index.htm;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
client_max_body_size 20M;
client_body_buffer_size 1024k;
error_log /var/log/nginx/billrun.error.log info;
access_log /var/log/nginx/billrun.access.log;
client_header_timeout 30m;
send_timeout 30m;
keepalive_requests 1024;
keepalive_timeout 10000;
index index.php index.html index.htm;
"'
location = / {
return 301 $scheme://$host/index.html;
}
if ( !-e $request_filename ) {
rewrite ^/(.*) /index.php last;
}
'"
location ~ .*.php\$ {
root $BILLRUN_DIR/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_read_timeout 1000s;
fastcgi_send_timeout 1000s;
fastcgi_connect_timeout 1000s;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param APPLICATION_ENV test; # Please put the correct environment manually
}
listen 80;
server_name $BILLRUN_HOSTNAME;
root $BILLRUN_DIR/public;
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt|woff|woff2)\$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control public;
}
}" | sudo tee -a /etc/nginx/conf.d/billrun-backend.conf
Change the user of the php-fpm to be <billrun_user>:
File content should be:
user = <billrun_user>
group = <httpd_group>
This user / group must have read/write permission to the directory where the sessions are stored. Find out this folder by issuing the next command (this folder may be different through the web server - use "phpinfo();" if not certain):
$ php -i | grep save_path
Uncomment in <Main Configuration Directory>/php/conf/php.ini or /etc/php.ini
date.timezone, and set it to :
date.timezone ='<Local timezone>' (for example: ‘Europe/Monaco’ )
And also set the following variable values :
memory_limit = 16384M
post_max_size = 256M
max_execution_time = 300
$ export BILLRUN_DIR=<Application Directory full path>
$ sudo git clone git@git.bill.run:sdoc/billrun.git $BILLRUN_DIR
$ sudo mkdir $BILLRUN_DIR/logs/
$ sudo chown -R <billrun_user>:apache $BILLRUN_DIR
$ sudo chmod 775 $BILLRUN_DIR
$ cd $BILLRUN_DIR
$ export GIT_SSL_NO_VERIFY=1
$ sudo -u <billrun_user> chmod 777 $BILLRUN_DIR/logs/
(NOTE : DO THIS ONLY ONCE PER DB PER BILLRUN INSTALLATION!)
Set the DB indexes :
$ mongo billing -u <admin user> -p < $BILLRUN_DIR/mongo/create.ini
Apply sharding:
$ mongo admin -u <admin user> -p < $BILLRUN_DIR/mongo/sharding.ini
Import the initial configuration:
$ mongoimport -d billing -c config < $BILLRUN_DIR/mongo/base/config.export --batchSize 1
Import the default tax rate (since v5.11):
$ mongoimport -d billing -c taxes < $BILLRUN_DIR/mongo/base/taxes.export --batchSize 1
Import the initial users:
$ mongoimport -d billing -c users < $BILLRUN_DIR/mongo/first_users.json
Please notice: default user & password are admin & 12345678 accordingly. Please change it after first login.
$ sudo service httpd restart
$ sudo service php71-fpm restart
$ sudo service nginx restart
http://ulaptech.blogspot.co.il/2011/01/fatal-error-uncaught-exception.html
$ sudo -P setsebool httpd_can_network_connect 1
$ sudo -P setsebool httpd_can_network_connect_db 1
The debug.log file or the log directory might not be configured on the billrun user
$ sudo chown -R <billrun_user>:<http_user> $BILLRUN__DIR/logs
$ sudo chmod 775 $BILLRUN__DIR/logs
$ sudo chmod 664 $BILLRUN__DIR/logs/*.log
This might be caused because the /tmp directory isn’t world executable as explained here :
To fix it run the following :
$ mkdir /root/tmp
$ pear config-set temp_dir /root/tmp
or if pear doesn’t work :
$ pecl config-set temp_dir /root/tmp
systemctl calming that mongos.service doesn’t exists , run the following :
$ systemctl deamon-reload
This issue might be caused due to the way that systemd handles systemv init.d scripts.
Make sure that the PID file path specified in the mongos.conf is the same as the path specified in the top commented out section of /etc/init.d/mongos under “# pidfilepath : ….”
$ sudo yum install -y https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm
$ sudo yum -y install fontconfig libXext urw-fonts
$ wget 'https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1.tar.bz2'
$ mkdir /opt/wkhtmltox && cd /opt/wkhtmltox && tar -xjf ~/wkhtmltox-0.12.1.tar.bz2
Install the poppler package that contains the pdf2ps executable
$ sudo yum install poppler
When a new version is created we need to move to that version in git (for example moving to alpha_4):
$ sudo su <billrun_user>
$ cd $BILLRUN_DIR
$ export GIT_SSL_NO_VERIFY=1 #this will tell git that the identity of the ssh sig. doesn’t have to be verified
$ git fetch --tags # to fetch all the update information from the remote git repository
$ git tag # this will display all the available tags
v5.6.7
v5.6.8
v5.6.9
...
v5.8.5.6
v5.8.6
v5.8.6.1
v5.8.7
For example, the next command will checkout the 5.8.7 version (tag):
$ git checkout v5.8.7
$ mongo billing -ubillrun -ppassword mongo/migration/script.js # User billrun must have the "dbAdmin" role
(also true for any other git conflicting files)
$ git diff | tee ~/”`date +%Y%m%d`”.patch
$ git checkout conf/prod.ini
$ git apply -v ~/"`date +%Y%m%d`"_prod.patch
(This might fail so the merging might need to be done manually with vimdiff)