OpenProject

 

Bel outils de gestion de projet en ruby avec du node !

à partir de cette page.

Créer l’utilisateur openproject :

sudo groupadd openproject
sudo useradd --create-home --gid openproject openproject
sudo passwd openproject #(enter desired password)
chsh -s /bin/bash openproject
usermod -G sudo -a openproject

Installer les composants nécessaires :

sudo apt-get update -y
sudo apt-get install -y zlib1g-dev build-essential                  \
                    libssl-dev libreadline-dev                      \
                    libyaml-dev libgdbm-dev                         \
                    libncurses5-dev automake                        \
                    imagemagick libmagickcore-dev libmagickwand-dev \
                    libtool bison libffi-dev git curl               \
                    libxml2 libxml2-dev libxslt1-dev                \
                    libssl1.0-dev mysql-server memcached            \
                    default-libmysqlclient-dev mysql-server

Créer la base de données pour openproject

mysql -uroot -p
mysql> CREATE DATABASE openproject CHARACTER SET utf8;
mysql> CREATE USER 'openproject'@'localhost' IDENTIFIED BY 'my_password';
mysql> GRANT ALL PRIVILEGES ON openproject.* TO 'openproject'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> QUIT

Récupérer ruby et node pour le compte openproject.

su openproject --login
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(rbenv init -)"' >> ~/.profile
source ~/.profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

rbenv install 2.4.1
rbenv rehash
rbenv global 2.4.1

git clone https://github.com/OiNutter/nodenv.git ~/.nodenv
echo 'export PATH="$HOME/.nodenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(nodenv init -)"' >> ~/.profile
source ~/.profile
git clone git://github.com/OiNutter/node-build.git ~/.nodenv/plugins/node-build

nodenv install 6.11.3
nodenv rehash
nodenv global 6.11.3

Récupérer OpenProject

cd ~
git clone https://github.com/opf/openproject-ce.git --branch stable/7 --depth 1
cd openproject-ce
gem install bundler
bundle install --deployment --without postgres sqlite development test therubyracer docker

npm install

# for raspberry pi or other if phantomjs does not install
git clone https://github.com/piksel/phantomjs-raspberrypi.git
chmod +x phantomjs-raspberrypi/bin/phantomjs
cp phantomjs-raspberrypi/bin/phantomjs /home/openproject/.nodenv/shims/
npm install phantomjs
npm install
# for raspberry pi

Copier

cp config/database.yml.example config/database.yml

puis renseigner les informations pour la connexion à la base de donnée dans le ficher /home/openproject/openproject-ce/config/database.yml

production:
  adapter: mysql2
  database: openproject
  host: localhost
  username: openproject
  password: my_password
  encoding: utf8

development:
  adapter: mysql2
  database: openproject
  host: localhost
  username: openproject
  password: my_password
  encoding: utf8

Copier

cp config/configuration.yml.example config/configuration.yml

puis renseigner les informations pour la configuration dans le fichier /home/openproject/openproject-ce/config/configuration.yml:

cp config/configuration.yml.example config/configuration.yml
production:                          #main level
  email_delivery_method: :smtp       #settings for the production environment
  smtp_address: smtp.gmail.com
  smtp_port: 587
  smtp_domain: smtp.gmail.com
  smtp_user_name: ***@gmail.com
  smtp_password: ****
  smtp_enable_starttls_auto: true
  smtp_authentication: plain
[...]
rails_cache_store: :memcache

Lancer le site en production

cd ~/openproject-ce
RAILS_ENV="production" ./bin/rake db:create
RAILS_ENV="production" ./bin/rake db:migrate
RAILS_ENV="production" ./bin/rake db:seed
RAILS_ENV="production" ./bin/rake assets:precompile

Le tester.

RAILS_ENV="production" npm run webpack-watch &
RAILS_ENV="production" ./bin/rails server

Remplir la clé.

echo "export SECRET_KEY_BASE=$(./bin/rake secret)" >> ~/.profile
source ~/.profile

Faire le lien avec apache2

sudo apt-get install -y apache2 libcurl4-gnutls-dev      \
                               apache2-dev libapr1-dev \
                               libaprutil1-dev
chmod o+x "/home/openproject"

su openproject --login
cd ~/openproject-ce
gem install passenger
passenger-install-apache2-module

Editer le fichier /etc/apache2/mods-available/passenger.load

LoadModule passenger_module /home/openproject/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/passenger-5.1.8/buildout/apache2/mod_passenger.so

Editer le fichier /etc/apache2/mods-available/passenger.conf

<IfModule mod_passenger.c>
     PassengerRoot /home/openproject/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/passenger-5.1.8
  PassengerDefaultRuby /home/openproject/.rbenv/versions/2.3.0/bin/ruby
</IfModule>
[root@openproject] a2enmod passenger

Editer le fichier /etc/apache2/sites-available/openproject.conf

SetEnv EXECJS_RUNTIME Disabled

<VirtualHost *:80>
   ServerName yourdomain.com
   # !!! Be sure to point DocumentRoot to 'public'!
   DocumentRoot /home/openproject/openproject-ce/public
   <Directory /home/openproject/openproject-ce/public>
      # This relaxes Apache security settings.
      AllowOverride all
      # MultiViews must be turned off.
      Options -MultiViews
      # Uncomment this if you're on Apache >= 2.4:
      Require all granted
   </Directory>

   # Request browser to cache assets
   <Location /assets/>
#     ExpiresActive On ExpiresDefault "access plus 1 year"
   </Location>

</VirtualHost>

Désactiver le site par défaut et activer openproject :

[root@host] a2dissite 000-default
[root@host] a2ensite openproject

Installer le cron

su --login openproject
crontab -e

et ajouter la ligne

*/10 * * * * cd /home/openproject/openproject-ce; /home/openproject/.rbenv/versions/2.4.1/bin/rake jobs:workoff

pour qu’il se lance toute les 10 minutes

Et pour l’avoir sur localhost/openproject

  • editer le fichier /etc/apache2/sites-available/openproject.conf:
SetEnv EXECJS_RUNTIME Disabled

<VirtualHost *:80>
   ServerName yourdomain.com
   # !!! Be sure to point DocumentRoot to 'public'!
   <Directory /home/openproject/openproject-ce/public>
      # This relaxes Apache security settings.
      AllowOverride all
      # MultiViews must be turned off.
      Options -MultiViews
      # Uncomment this if you're on Apache >= 2.4:
      Require all granted
   </Directory>

   # Request browser to cache assets
   <Location /assets/>
#     ExpiresActive On ExpiresDefault "access plus 1 year"
   </Location>

# These have been added:
    Alias /openproject /home/openproject/openproject-ce/public
    <Location /openproject>
        PassengerBaseURI /openproject
        PassengerAppRoot /home/openproject/openproject-ce

    </Location>
    <Directory /home/openproject/openproject-ce/public>
        Allow from all
        Options -MultiViews
        # Uncomment this if you're on Apache >= 2.4:
        #Require all granted
    </Directory>


</VirtualHost>
  • editer le fichier /home/openproject/openproject-ce/config/configuration.yml:
[...]
  rails_relative_url_root: "/openproject"
[...]
  • relancer la précompilation des assets avec le nouvel url
    RAILS_ENV="production" ./bin/rake assets:precompile

     

  • relancer le serveur apache
    sudo systemctl reload apache2

    Pour l’installer en tant que service sous windows, utiliser ‘thin’

    gem install thin
    gem install thin_service