Mémo - Installation de DreamFactory

L’installation de Dreamfactory par une image Bitnami est très bien pour tester, mais elle me fait craindre quelques problèmes de stabilité. C’est un peu caca, bitnami en met partout, dur de s’y retrouver lorsque des optimisations sont à faire coté apache php ou mysql etc... et les scripts Bitnami de redémarrages de services oublient de faire des logrotates et font d’autres erreurs.

Bref avant de passer Dreamfactory en production, installons le proprement à la main. voici le mémo.

Le wiki de Dreamfactory explique bien comment faire. http://wiki.dreamfactory.com/DreamFactory/Installation je m’attacherai ici à détailler un eu plus, dont le paramétrage serveur.

Prérequis

Débian 8 Fraichement installée.

Je choisis un trio PHP7 + Apache + mysql

Apache, php et ses modules, et autres prérequis

ajouter le dépôt dotdeb

PHP 7 n’est pas dans les dépôts de la version stable de debian. C’est la logique de leur cycle de développement, ils ne sortent pas de version majeures d un logiciel. On va donc utiliser le dépôt dotdeb.

echo "deb http://packages.dotdeb.org jessie all" > /etc/apt/sources.list.d/dotdeb.list
wget -O- https://www.dotdeb.org/dotdeb.gpg | apt-key add -
apt-get update

’’Source’

Installer tous paquets nécessaires directement et indirectement à dreamfactory.

apt-get install git curl apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-gd php7.0-mcrypt php7.0-msgpack php7.0-memcached php7.0-intl php7.0-sqlite3 php7.0-gmp php7.0-geoip php7.0-mbstring php7.0-xml php7.0-zip php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-gd php7.0-mcrypt php7.0-msgpack php7.0-memcached php7.0-intl php7.0-sqlite3 php7.0-gmp php7.0-geoip php7.0-mbstring php7.0-xml php7.0-zip php7.0-dev php-pear mysql-server mysql-client libcurl4-openssl-dev pkg-config
pecl channel-update pecl.php.net
#la lib mongodb est un peu chiante à installer 
#(Plusieurs paquets ci dessus en sont des prérequis, et il faut enregistrer le module)
pecl install mongodb-alpha
echo "extension=mongodb.so">/etc/php/7.0/cli/conf.d/20-mongo.ini
echo "extension=mongodb.so">/etc/php/7.0/mods-available/mongo.ini

Mettez un mot de passe root à mysql quand il le demande.

php.ini

vi /etc/php/7.0/apache2/php.ini Si votre API dreamfactory aura aussi pour vocation du transfert de fichiers, relevez les valeurs par défaut en fonction de vos besoins.

post_max_size = 40M
upload_max_filesize = 40M
max_file_uploads = 20

Composer

curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Créer une base mysql

mysql -u root -p
CREATE DATABASE dreamfactory;
GRANT ALL ON dreamfactory.* TO 'dreamfactory'@'localhost' IDENTIFIED BY '*hjiQM,NER!';
quit

Installer dreamfactory

cd /var/www
git clone https://github.com/dreamfactorysoftware/dreamfactory.git
cd dreamfactory/
composer install --no-dev
php artisan dreamfactory:setup

Voici mon retour écran pour la dernière commande:

root@dreamfactory:/var/www/dreamfactory# php artisan dreamfactory:setup
**********************************************************************************************************************
* Configuring DreamFactory... 
**********************************************************************************************************************
Created .env file with default configuration.
Application key [base64:9AZJkz07XobEu5IQ72kRCVjIiJKUg0HrhY/WD1McPUw=] set successfully.
Created phpunit.xml with default configuration.

 Which database would you like to use for system tables? [sqlite]:
  [0] sqlite
  [1] mysql
  [2] pgsql
  [3] sqlsrv
 > 1

 Enter your mysql Host:
 > localhost

 Enter your database name:
 > dreamfactory

 Enter your database username:
 > dreamfactory

 Enter your database password:
 > 

 Re-enter your database password:
 > 

 Enter your Database Port [3306]:
 > 

CACHE DRIVER  is not supported. Using default driver file.
Configuration complete!
*************************************************** WARNING! *********************************************************
*
* Please take a moment to review the .env file. You can make any changes as necessary there. 
*
* Please run "php artisan dreamfactory:setup" again to complete the setup process.
*
**********************************************************************************************************************

Un petit tour dans le fichier .env nous indique entre autre qu’il veut bien de redis comme systeme de cache. Let’s do it:

apt-get install redis-server

Maintenant on édite le fichier .env, et on gère le cache comme ça:

##------------------------------------------------------------------------------
## Cache and Session Settings
##------------------------------------------------------------------------------

CACHE_DRIVER=redis
SESSION_DRIVER=array
MAIL_DRIVER=mail

##------------------------------------------------------------------------------
## Redis cache settings.  Uncomment if the CACHE_DRIVER is changed to redis and
## the default values are not appropriate
##------------------------------------------------------------------------------

REDIS_HOST=127.0.0.1
REDIS_PORT=6379
#REDIS_DATABASE=
#REDIS_PASSWORD=

On relance la commande:

php artisan dreamfactory:setup

Voici mon retour écran

root@dreamfactory:/var/www/dreamfactory# php artisan dreamfactory:setup
**********************************************************************************************************************
* Welcome to DreamFactory setup wizard.
**********************************************************************************************************************
Running Migrations...
Migration table created successfully.
Migration driver used: mysql
Migrated: 2015_01_27_190908_create_system_tables
Migrated: 2015_02_03_161456_create_sqldb_tables
Migrated: 2015_02_03_161457_create_couchdb_tables
Migrated: 2015_02_03_161457_create_mongodb_tables
Migrated: 2015_03_10_135522_create_aws_tables
Migrated: 2015_03_10_200756_create_azure_tables
Migrated: 2015_03_11_143913_create_rackspace_tables
Migrated: 2015_03_20_205504_create_remote_web_service_tables
Migrated: 2015_05_02_134911_update_user_table_for_oauth_support
Migrated: 2015_05_21_190727_create_user_config_table
Migrated: 2015_07_10_161839_create_user_custom_table
Migrated: 2015_08_25_202632_db_alias
Migrated: 2015_11_06_155036_db_function
Migrated: 2015_11_10_225902_db_foreign_key
Migrated: 2016_01_21_213101_add_curl_options
Migrated: 2016_03_15_235903_add_username_field_to_user_table
Migrated: 2016_05_11_134231_remove_service_and_script_type
Migrated: 2016_05_17_020359_db_config_add
Migrated: 2016_06_20_195319_event_affects_content
Migrated: 2016_07_11_155716_create_cassandra_config_table
Migrated: 2016_07_25_214132_adding_a_custom_field_for_oauth_config
Migrated: 2016_08_02_153513_create_redis_config_table
Migrated: 2016_08_02_193216_create_local_cache_config
Migrated: 2016_08_04_140705_create_memcached_config_table
Migrated: 2016_08_09_202900_create_jobs_table
Migrated: 2016_08_10_145124_create_failed_jobs_table
Migrated: 2016_08_10_191349_queueable_scripts
Migration completed successfully.
**********************************************************************************************************************
**********************************************************************************************************************
Running Seeder...
Service resources created: system, api_docs, files, db
Seeded: DreamFactory\Core\Models\Seeds\ServiceSeeder
App resources created: admin, api_docs, file_manager
Seeded: DreamFactory\Core\Models\Seeds\AppSeeder
Email Template resources created: User Invite Default, User Registration Default, Password Reset Default
Seeded: DreamFactory\Core\User\Models\Seeds\EmailTemplateSeeder
Service resources created: email
Seeded: DreamFactory\Core\User\Models\Seeds\EmailServiceSeeder
Service resources created: user
Seeded: DreamFactory\Core\User\Models\Seeds\UserServiceSeeder
Seeded: DreamFactory\Core\User\Models\Seeds\DatabaseSeeder
All tables were seeded successfully.
**********************************************************************************************************************
**********************************************************************************************************************
Creating the first admin user...

 Enter your first name:
 > Gnieark

 Enter your last name:
 > Grouik

 Enter display name:
 > Gnieark Grouik

 Enter your email address?:
 > gnieark@domaoine.com

 Choose a password:
 > 

 Re-enter password:
 > 

Successfully created first admin user.
**********************************************************************************************************************
*************************************************** WARNING! *********************************************************
* Please make sure following directories and all directories under them are readable and writable by your web server 
*   -> storage/
*   -> bootstrap/cache/
* Example:
*      > sudo chown -R {www user}:{your user group} storage/ bootstrap/cache/ 
*      > sudo chmod -R 2775 storage/ bootstrap/cache/ 
**********************************************************************************************************************
*********************************************** Setup Successful! ****************************************************
* Setup is complete! Your instance is ready. Please launch your instance using a browser.
* You can run "php artisan serve" to try out your instance without setting up a web server.
**********************************************************************************************************************

On applique les droits:

chown -R www-data:www-data storage/ bootstrap/cache/ 
chmod -R 2775 storage/ bootstrap/cache/

Configuration d’apache

a2enmod rewrite

Editer le fichier /etc/apache2/sites-available/000-default.conf Pour y mettre:

<VirtualHost *:80>
    DocumentRoot /var/www/dreamfactory/public

    <Directory /var/www/dreamfactory/public>
        AddOutputFilterByType DEFLATE text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript
        Options -Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        AllowOverride None
        Require all granted
        RewriteEngine on
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^.*$ /index.php [L]

        <LimitExcept GET HEAD PUT DELETE PATCH POST>
            Allow from all
        </LimitExcept>
    </Directory>
</VirtualHost>
service apache2 restart

Se rendre sur le serveur via un navigateur: Capture_du_2016-09-18_23-50-53.png

Voila, Il ne reste plus qu’à configurer apache pour le https, mais ça, je vous laisse faire.

Ajouter un commentaire

Les commentaires peuvent être formatés en utilisant une syntaxe wiki simplifiée.

La discussion continue ailleurs

URL de rétrolien : https://blog-du-grouik.tinad.fr/trackback/923

Fil des commentaires de ce billet

Page top