Ubuntu 16.04

Prérequis

Pour utiliser Communecter vous devez avoir

  • Apache 2 & PHP 5.6 (Attention, ne fonctionne pas sur PHP 7)

    • sudo apt-get install apache2 php5.6

    • Pour passer de la version 7 à 5.6 vous pouvez suivre la solution suivante : https://askubuntu.com/questions/761713/how-can-i-downgrade-from-php-7-to-php-5-6-on-ubuntu-16-04

    • Certains modules doivent être installé

      • rewrite sudo a2enmod rewrite
      • curl sudo apt-get install php5.6-curl
      • mcrypt sudo apt-get install php5.6-mcrypt
      • gd sudo apt-get install php5.6-gd
      • mongo sudo apt-get install php5.6-mongo
      • dom sudo apt-get install php5.6-dom
    • Pour vérifier votre version de PHP php -v

  • MongoDB 3.4 (Ne fonctionne pas avec la 3.6) :

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org

Install

Clone from GitHub :

mkdir /home/[nameUser]/dev/communecter 
mkdir /home/[nameUser]/dev/communecter/modules 
cd /var/www/html/
sudo ln -s /home/[nameUser]/dev/communecter communecter
cd /home/[nameUser]/dev/communecter
git clone https://github.com/pixelhumain/pixelhumain.git
cd modules/
git clone https://github.com/pixelhumain/citizenToolKit.git
git clone https://github.com/pixelhumain/co2.git
ln -s co2 network
git clone https://github.com/pixelhumain/api
git clone https://github.com/pixelhumain/graph.git
git clone https://github.com/pixelhumain/classifieds.git
git clone https://github.com/pixelhumain/ressources.git
git clone https://github.com/pixelhumain/places.git
git clone https://github.com/pixelhumain/chat.git
git clone https://github.com/pixelhumain/learn.git
git clone https://github.com/pixelhumain/survey.git
git clone https://github.com/pixelhumain/interop.git
git clone https://github.com/pixelhumain/cotools.git
git clone https://github.com/pixelhumain/eco.git
cd ../

Installer les dépendances avec Composer :

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

Rename the dbconfig file :

cd protected/
cp config/dbconfig.exemple.php config/dbconfig.php

Création du dossier runtime et assets

mkdir /runtime
sudo chmod -R 775 runtime/
cd ../
mkdir /assets
sudo chmod -R 775 assets/
cd ../
sudo chown -R votreUser:www-data pixelhumain
sudo chown -R votreUser:www-data modules

Configuration

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

<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	  
	  Alias "/ph" "/var/www/html/communecter/pixelhumain/ph"
	  <Directory "/var/www/html/communecter/pixelhumain/ph">
		Options FollowSymLinks Indexes
		AllowOverride none
		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>

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Activate the new vhost :

sudo a2ensite communecter 
sudo a2enmod rewrite 
sudo service apache2 reload

Configurer MongoDB

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

#Starting mongod (communecter Database Engine)
mongod --dbpath "/var/www/html/communecter/data/db"

#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 les données :

cd modules/co2/data
unzip cities.json.zip
mongoimport --db pixelhumain --collection cities --file cities.json

unzip translate.json.zip
mongoimport --db pixelhumain --collection translate --file translate.json

unzip zones.json.zip
mongoimport --db pixelhumain --collection zones --file zones.json

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

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 ../

Ajouter MongoDB au démarrage et faire le script d’utilisation : sudo nano /etc/init.d/communecterdb

Ajouter ceci :

#!/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 --dbpath /var/www/html/communecter/data/db

Sauvegardez :

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

Alternative : créer le script communecterdb.sh, le rendre exécutable et l’ajouter dans /etc/rc.local

Vérifier que tous les composants sont installés

Accéder a l’url suivant : http://127.0.0.1/ph/test
Et réglez tout les points rouges.

C’est bon vous pouvez utiliser COMMUNECTER

Accédez à cette adresse : http://127.0.0.1/ph/

Optionnel

Interface Mongo

Si vous souhaitez avoir une interface pour géré MongoDB vous pouvez télécharger Robo3T : https://robomongo.org/download

Email service to cron

Add

crontab -e : */2 * * * * curl https://127.0.0.1/ph/co2/test/docron

Use

Communecter is now available : http://127.0.0.1/ph/
To try the email service, go to http://127.0.0.1/ph/co2/test/docron

To use in production mode, edit index.php

Update

Create /var/www/html/communecter/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 "------------ CLASSIFIEDS -----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../classifieds
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 "------------ RESSOURCES -----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../ressources
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 "------------ PLACES -----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../places
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 "------------ CHAT -----------------"
echo "---------------------------------------------${reset}"
echo ""
cd ../chat
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.

Back to top