Installation of Communect on an Ubuntu server 16.04

Prerequisite

As Communect is written in PHP (using Yii framework), you need to install LAMP with PHP 5.6 (PHP 7 won't work because of mongo).

Communect uses MongoDB database. Add the repository in apt to /etc/sources.list.d/ and install (source) :

sudo su
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
apt update
apt install mongodb-org
service mongod start

Install

Clone from GitHub :

mkdir /var/www/communect && mkdir /var/www/communect/modules && cd /var/www/communect
git clone https://github.com/pixelhumain/pixelhumain
cd modules/
git clone https://github.com/pixelhumain/citizenToolKit
git clone https://github.com/pixelhumain/co2
git clone https://github.com/pixelhumain/network
git clone https://github.com/pixelhumain/api
git clone https://github.com/pixelhumain/opendata
git clone https://github.com/pixelhumain/cityData
cd ../

Install dependencies with Composer :

sudo apt install composer
cd pixelhumain/ph/
composer update
composer install

Rename the dbconfig file :

mv protected/config/dbconfig.exemple.php protected/config/dbconfig.php

Configure

Edit pixelhumain/ph/protected/config/dbconfig.php and pixelhumain/ph/protected/config/paramsconfig.php

Edit pixelhumain/ph/protected/config/main.php and check this : 'defaultController' => 'co2',

Edit pixelhumain/ph/protected/config/modules.php and replace : 'communecter', by

'co2module',
'co2',

And configure Apache vhost : edit /etc/apache2/sites-available/communect.conf :

<VirtualHost *:80>
        ServerName domain.ext
        ServerAdmin webmaster@domain.ext
        DocumentRoot /var/www/communect/pixelhumain/ph
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        Alias "/ph" "/var/www/communect/pixelhumain/ph"

        <Directory "/var/www/communect/pixelhumain/ph">
                Options FollowSymLinks Indexes
                AllowOverride all
                Order deny,allow
                Allow from 127.0.0.1
                #deny from all

                <IfModule mod_rewrite.c>
                        Options +FollowSymLinks
                        IndexIgnore */*
                        RewriteEngine on
                        RewriteCond %{REQUEST_FILENAME} !-f
                        RewriteCond %{REQUEST_FILENAME} !-d
                        RewriteCond $1 !^(index\.php|assets|robots\.txt)
                        RewriteRule ^(.*)$ /ph/index.php/$1 [L]
                </IfModule>
        </Directory>
</VirtualHost>

Activate the new vhost :

a2ensite communect && a2enmod rewrite && service apache2 reload

Configure MongoDB

#Making the Data folder for MongoDB
mkdir data/
mkdir data/db

#Starting mongod (communect Database Engine)
mongod --fork --dbpath "/var/www/communect/data/db" --logpath /var/log/mongod.log

#Making user adding script of pixelhumain user
echo 'db.createUser({     user: "pixelhumain",     pwd: "pixelhumain",     roles: [{role:"readWrite", db:"pixelhumain"}]})' > adduserpixelhumaindb.js                                                   
mongo pixelhumain adduserpixelhumaindb.js

#Deleting script after use
rm adduserpixelhumaindb.js

Import databases :

cd modules/co2/data
unzip cities.json.zip
mongoimport --db pixelhumain --collection cities cities.json --jsonArray;
# If error (new version) :
mongoimport --db pixelhumain --collection cities --file cities.json

mongoimport --db pixelhumain --collection lists lists.json --jsonArray ;

If you have the new version of Communect (in this case, you will have the error message "Missing Configs db.applications.key...") see here and do this :

mongo
  use pixelhumain
  db.createCollection("applications")
  db.applications.insert({     "_id" : ObjectId("59f1920bc30f30536124355d"),     "name" : "DEV Config",     "key" : "devParams",     "mangoPay" : {         "ClientId" : "communecter",         "ClientPassword" : "xxxx",         "TemporaryFolder" : "../../tmp"     } } )
  db.applications.insert({     "_id" : ObjectId("59f1920bc30f30536124355e"),     "name" : "PROD Config",     "key" : "prodParams",     "mangoPay" : {         "ClientId" : "communecter",         "ClientPassword" : "xxxx",         "TemporaryFolder" : "../../tmp"     } } )
  exit

cd ../

Adding mongodb at startup and making the using script :

sudo su
nano /etc/init.d/communectdb

Add this :

#!/bin/sh
#
### BEGIN INIT INFO
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Provides:          unattended-upgrade-shutdown-check
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
# Short-Description: Check if unattended upgrades are being applied
# Description:       Check if unattended upgrades are being applied
#                    and wait for them to finish
### END INIT INFO

mongod --fork --dbpath /var/www/communect/data/db --logpath /var/log/mongod.log

Save and :

chmod +x /etc/init.d/communectdb
update-rc.d communectdb defaults
update-rc.d communectdb enable

Alternative : create the script communectdb.sh, make it executable and add it in /etc/rc.local

Add email service to cron

crontab -e :

*/2 * * * * curl https://domain.ext/co2/test/docron

Use

Communecte is now available : http://domain.ext/ph/ To try the email service, go to http://domain.ext/co2/test/docron

To use in production mode, edit index.php

Update

Create /var/www/communect/update.sh containing :

red=`tput setaf 1`
green=`tput setaf 2`
blue=`tput setaf 0`
bgWhite=`tput setab 7`
reset=`tput sgr0`

cp pixelhumain/ph/protected/config/dbconfig.php .
cp pixelhumain/ph/protected/config/paramsconfig.php .

echo ""
echo "${green}${bgWhite}---------------------------------------------"
echo "------------ CO2  --------------------"
echo "---------------------------------------------${reset}"
echo ""
cd modules/co2
echo "${blue}${bgWhite}GIT STATS${reset}"
git status -sb
echo "${blue}${bgWhite}GIT LOGS${reset}"
git --no-pager log --pretty=format:"%h - %an, %ar : %s" --max-count=5
echo ""
echo "${blue}${bgWhite}GIT PULL${reset}"
git pull

echo ""
echo "${green}${bgWhite}---------------------------------------------"
echo "------------ CITIZEN TOOLKIT-----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../citizenToolKit
echo "${blue}${bgWhite}GIT STATS${reset}"
git status -sb
echo "${blue}${bgWhite}GIT LOGS${reset}"
git --no-pager log --pretty=format:"%h - %an, %ar : %s" --max-count=5
echo ""
echo "${blue}${bgWhite}GIT PULL${reset}"
git pull

echo ""
echo "${green}${bgWhite}---------------------------------------------"
echo "------------ NETWORK -----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../network
echo "${blue}${bgWhite}GIT STATS${reset}"
git status -sb
echo "${blue}${bgWhite}GIT LOGS${reset}"
git --no-pager log --pretty=format:"%h - %an, %ar : %s" --max-count=5
echo ""
echo "${blue}${bgWhite}GIT PULL${reset}"
git pull

echo ""
echo "${green}${bgWhite}---------------------------------------------"
echo "------------ API -----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../api
echo "${blue}${bgWhite}GIT STATS${reset}"
git status -sb
echo "${blue}${bgWhite}GIT LOGS${reset}"
git --no-pager log --pretty=format:"%h - %an, %ar : %s" --max-count=5
echo ""
echo "${blue}${bgWhite}GIT PULL${reset}"
git pull

echo ""
echo "${green}${bgWhite}---------------------------------------------"
echo "------------ PIXELHUMAIN --------------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../../pixelhumain
rm -f ph/protected/runtime/application.log
rm -Rf ph/assets/*

echo "${blue}${bgWhite}GIT STATS${reset}"
git status -sb
echo "${blue}${bgWhite}GIT LOGS${reset}"
git --no-pager log --pretty=format:"%h - %an, %ar : %s" --max-count=5
echo ""
echo "${blue}${bgWhite}GIT PULL${reset}"
git reset --hard HEAD
git pull

cp ../dbconfig.php ph/protected/config
cp ../paramsconfig.php ph/protected/config

#echo "${red}---------------------------------------------"
#echo "------------ GLOBAL STATS --------------------"
#echo "---------------------------------------------${reset}"
#git shortlog -s -n

Make it executable and launch it.

You can join us at any moment on the chat.

results matching ""

    No results matching ""