Laravel

De Hegyd Doc.

(Différences entre les versions)
(Installation nodejs et npm)
(Installation nodejs et npm)
 
(16 versions intermédiaires masquées)
Ligne 1 : Ligne 1 :
 +
== Pré-requis Serveur PHP==
 +
Pour fonctionner correctement Laravel a besoin de PHP :
 +
 +
Version >= 5.5.9
 +
Extension PDO
 +
Extension Mbstring
 +
Extension OpenSSL
 +
Extension Tokenizer
 +
Extension Zip
 +
NB: ces extensions sont par défaut dans PHP 5.6 sous Debian 8
 +
 +
Sous PHP 7 :
 +
apt-get install php7.0-zip php7.0-mbstring
 +
 +
Installation du driver natif mysql :
 +
apt-get install php5-mysqlnd
 +
== Installation de composer ==
== Installation de composer ==
http://www.johnstyle.fr/composer-installation-sur-debian-7
http://www.johnstyle.fr/composer-installation-sur-debian-7
Ligne 26 : Ligne 43 :
</pre>
</pre>
 +
NodeJS 6 (Debian 7)
 +
<pre>curl -sL https://deb.nodesource.com/setup_6.x | bash -
 +
apt-get install -y nodejs
 +
</pre>
-
NodeJS 4
+
NodeJS 8 (Debian 8 min)
-
<pre>curl -sL https://deb.nodesource.com/setup_4.x | bash -
+
<pre>curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
apt-get install -y nodejs
</pre>
</pre>
 +
 +
NodeJS 10 (Debian 8 min)
 +
<pre>curl -sL https://deb.nodesource.com/setup_10.x | bash -
 +
apt-get install -y nodejs
 +
</pre>
 +
 +
NodeJS 12 (Debian 8 min)
 +
<pre>curl -sL https://deb.nodesource.com/setup_12.x | bash -
 +
apt-get install -y nodejs
 +
</pre>
 +
 +
Node.js LTS (14.x)
 +
<pre>
 +
# As root
 +
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
 +
## To install Node.js 14.x and npm
 +
apt-get install -y nodejs
 +
## You may also need development tools to build native addons:
 +
apt-get install gcc g++ make
 +
## To install the Yarn package manager, run:
 +
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
 +
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
 +
sudo apt-get update && sudo apt-get install yarn
 +
</pre>
 +
Il faudra forcer l'update de npm
Il faudra forcer l'update de npm
Ligne 40 : Ligne 86 :
<pre>npm install -g bower
<pre>npm install -g bower
apt-get install tig</pre>
apt-get install tig</pre>
 +
 +
== Installation optipng ==
 +
<pre>apt-get remove optipng
 +
npm install --global optipng-bin</pre>
 +
Source : https://github.com/imagemin/optipng-bin
 +
 +
== Installation Mailcatcher ==
 +
Réf : https://mailcatcher.me/
 +
 +
== Procédure installation mailcatcher ==
 +
 +
 +
Prérequis
 +
<pre>apt-get update
 +
apt-get install ruby-dev libsqlite3-dev rubygems build-essential</pre>
 +
 +
= Installation Gem =
 +
Sur debian 8 :
 +
<pre> gem install mailcatcher </pre>
 +
 +
= Création utilisateur applicatif=
 +
useradd mailcatcher
 +
 +
= Création script init.d=
 +
<pre>
 +
cat >> /etc/init.d/mailcatcher <<EOF
 +
#! /bin/sh
 +
### BEGIN INIT INFO
 +
# Provides: mailcatcher
 +
# Required-Start: \$remote_fs \$syslog
 +
# Required-Stop: \$remote_fs \$syslog
 +
# Default-Start: 2 3 4 5
 +
# Default-Stop: 0 1 6
 +
# Short-Description: mailcatcher
 +
# Description: This file starts and stops mailcatcher daemon
 +
#
 +
### END INIT INFO
 +
 +
MAILCATCHER_EXEC=`which mailcatcher`
 +
 +
case "\$1" in
 +
start)
 +
  su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0'
 +
  ;;
 +
stop)
 +
  killall mailcatcher
 +
  sleep 5
 +
  ;;
 +
restart)
 +
  killall mailcatcher
 +
  sleep 5
 +
  su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0'
 +
  ;;
 +
*)
 +
  echo "Usage: mailcatcher {start|stop|restart}" >&2
 +
  exit 3
 +
  ;;
 +
esac
 +
EOF
 +
</pre>
 +
 +
= Ajouts des droits d'execution du script =
 +
 +
chmod 775 /etc/init.d/mailcatcher
 +
 +
= Lancement automatique au démarrage de la VM =
 +
 +
update-rc.d mailcatcher defaults
 +
 +
= Démarrage mailcatcher =
 +
/etc/init.d/mailcatcher start
 +
 +
== Configuration Apache2 ==
 +
 +
Il faut remplacer FQDN pour le nom complet de la vm (demander à Antoine la création de l'entrée DNS)
 +
 +
= Ajouter au vhost du projet =
 +
<pre>
 +
<VirtualHost *:80>
 +
    ProxyPreserveHost On
 +
    ProxyPass / http://localhost:1080/
 +
    ProxyPassReverse / http://localhost:1080/
 +
    ServerName mailcatcher.FQDN
 +
    ServerAlias *.mailcatcher.FQDN
 +
    <Proxy *>
 +
    Order deny,allow
 +
            Deny from all
 +
            Allow from 127.0.0.1 ::1
 +
            Allow from 46.18.122.14
 +
            Allow from 176.31.218.41
 +
            Allow from 88.161.155.75
 +
            Allow from 81.252.255.73
 +
            Allow from 79.98.21.16
 +
            Allow from 78.238.152.36
 +
            Allow from 37.32.61.134
 +
            #ip firewall
 +
            Allow from 86.195.180.237
 +
            Allow from 105.157.136.41
 +
            Allow from 88.180.237.39
 +
            Allow from 89.81.145.139
 +
            Allow from 41.249.105.102
 +
            Allow from 92.151.4.18
 +
            Allow from 82.120.72.45
 +
            Allow from 41.142.242.218
 +
    Allow from 185.132.64.180
 +
            AuthType Basic
 +
            AuthName "MailCatcher"
 +
            AuthUserFile /var/projects/common/.htpasswd
 +
            Require valid-user
 +
            Satisfy any
 +
    </Proxy>
 +
 +
</VirtualHost>
 +
</pre>
 +
 +
= Activer mod proxy =
 +
 +
a2enmod proxy_http proxy
 +
 +
= Redémarrer l'apache=
 +
 +
service apache2 restart
 +
 +
= Tester sur l'adresse http://mailcatcher.FQDN_VM =
 +
 +
--
 +
Pour executer plusieurs instances, il faut modifier le port d'écouter smtp et http dans le fichier init.d :
 +
 +
Exemple:
 +
 +
cp /etc/init.d/mailcatcher /etc/init.d/mailcatcher-galilea
 +
 +
puis spécifier le nouveau port dans la commande de lancement (vérifier les ports en écoute avec un netstat -plnt)
 +
<pre>
 +
case "$1" in
 +
start)
 +
  su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0 --smtp-port 1026 --http-port 1081'
 +
  ;;
 +
stop)
 +
  killall mailcatcher
 +
  sleep 5
 +
  ;;
 +
restart)
 +
  killall mailcatcher
 +
  sleep 5
 +
  su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0 --smtp-port 1026 --http-port 1081'
 +
  ;;
 +
*)
 +
</pre>
 +
Attention tout stop/redémarrage du service stoppera toutes les instances mailcatcher présentes sur le serveur (présence du killall) !!!!
 +
 +
== Installation d'un certificat auto-signé pour la preprod (si besoin) ==
 +
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout preprod.redlink.hegyd.net.key -out preprod.redlink.hegyd.net.crt
 +
 +
Ajout du vhost dans le fichier de conf apache :
 +
<pre><VirtualHost *:443>
 +
        DocumentRoot /var/projects/redlink/preprod/public
 +
        ServerName preprod.redlink.hegyd.net
 +
        ServerAlias *.preprod.redlink.hegyd.net
 +
        SetEnv APPLICATION_ENV preproduction
 +
        SSLENgine On
 +
        SSLCertificateFile  /etc/ssl/preprod.redlink.hegyd.net/preprod.redlink.hegyd.net.crt
 +
        SSLCertificateKeyFile /etc/ssl/preprod.redlink.hegyd.net/preprod.redlink.hegyd.net.key
 +
 +
        Alias /media /var/projects/redlink/preprod/storage
 +
        <directory /var/projects/redlink/preprod/storage>
 +
            options indexes followsymlinks
 +
            order allow,deny
 +
            allow from all
 +
        </directory>
 +
</VirtualHost>
 +
</pre>
[[Catégorie:Administration serveurs]]
[[Catégorie:Administration serveurs]]

Version actuelle en date du 22 décembre 2020 à 09:06

Sommaire

[modifier] Pré-requis Serveur PHP

Pour fonctionner correctement Laravel a besoin de PHP :

Version >= 5.5.9
Extension PDO
Extension Mbstring
Extension OpenSSL
Extension Tokenizer
Extension Zip

NB: ces extensions sont par défaut dans PHP 5.6 sous Debian 8

Sous PHP 7 :

apt-get install php7.0-zip php7.0-mbstring

Installation du driver natif mysql :

apt-get install php5-mysqlnd

[modifier] Installation de composer

http://www.johnstyle.fr/composer-installation-sur-debian-7

Télécharger composer

apt-get update && apt-get install curl
curl -s https://getcomposer.org/installer | php

Déplacer composer dans le dossier /usr/local/bin/

mv composer.phar /usr/local/bin/composer

Composer est installé

composer --version

[modifier] Installation nodejs et npm

Site de référence : https://github.com/nodesource/distributions

NodeJS 0.10

curl -sL https://deb.nodesource.com/setup | bash -
apt-get install -y nodejs
apt-get install npm

NodeJS 6 (Debian 7)

curl -sL https://deb.nodesource.com/setup_6.x | bash -
apt-get install -y nodejs

NodeJS 8 (Debian 8 min)

curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs

NodeJS 10 (Debian 8 min)

curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs

NodeJS 12 (Debian 8 min)

curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

Node.js LTS (14.x)

# As root
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
## To install Node.js 14.x and npm
apt-get install -y nodejs
## You may also need development tools to build native addons:
apt-get install gcc g++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

Il faudra forcer l'update de npm

npm -g install npm@latest

[modifier] Installation bower et tig

npm install -g bower
apt-get install tig

[modifier] Installation optipng

apt-get remove optipng
npm install --global optipng-bin

Source : https://github.com/imagemin/optipng-bin

[modifier] Installation Mailcatcher

Réf : https://mailcatcher.me/

[modifier] Procédure installation mailcatcher

Prérequis

apt-get update
apt-get install ruby-dev libsqlite3-dev rubygems build-essential

[modifier] Installation Gem

Sur debian 8 :

	gem install mailcatcher 

[modifier] Création utilisateur applicatif

useradd mailcatcher

[modifier] Création script init.d

cat >> /etc/init.d/mailcatcher <<EOF
#! /bin/sh
### BEGIN INIT INFO
# Provides: mailcatcher
# Required-Start: \$remote_fs \$syslog
# Required-Stop: \$remote_fs \$syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mailcatcher
# Description: This file starts and stops mailcatcher daemon
#
### END INIT INFO

MAILCATCHER_EXEC=`which mailcatcher`

case "\$1" in
 start)
   su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0'
   ;;
 stop)
   killall mailcatcher
   sleep 5
   ;;
 restart)
   killall mailcatcher
   sleep 5
   su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0'
   ;;
 *)
   echo "Usage: mailcatcher {start|stop|restart}" >&2
   exit 3
   ;;
esac
EOF

[modifier] Ajouts des droits d'execution du script

chmod 775 /etc/init.d/mailcatcher

[modifier] Lancement automatique au démarrage de la VM

update-rc.d mailcatcher defaults

[modifier] Démarrage mailcatcher

/etc/init.d/mailcatcher start

[modifier] Configuration Apache2

Il faut remplacer FQDN pour le nom complet de la vm (demander à Antoine la création de l'entrée DNS)

[modifier] Ajouter au vhost du projet

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyPass / http://localhost:1080/
    ProxyPassReverse / http://localhost:1080/
    ServerName mailcatcher.FQDN
    ServerAlias *.mailcatcher.FQDN
    <Proxy *>
    Order deny,allow
            Deny from all
            Allow from 127.0.0.1 ::1
            Allow from 46.18.122.14
            Allow from 176.31.218.41
            Allow from 88.161.155.75
            Allow from 81.252.255.73
            Allow from 79.98.21.16
            Allow from 78.238.152.36
            Allow from 37.32.61.134
            #ip firewall
            Allow from 86.195.180.237
            Allow from 105.157.136.41
            Allow from 88.180.237.39
            Allow from 89.81.145.139
            Allow from 41.249.105.102
            Allow from 92.151.4.18
            Allow from 82.120.72.45
            Allow from 41.142.242.218
	    Allow from 185.132.64.180
            AuthType Basic
            AuthName "MailCatcher"
            AuthUserFile /var/projects/common/.htpasswd
            Require valid-user
            Satisfy any
    </Proxy>

</VirtualHost>

[modifier] Activer mod proxy

a2enmod proxy_http proxy

[modifier] Redémarrer l'apache

service apache2 restart

[modifier] Tester sur l'adresse http://mailcatcher.FQDN_VM

-- Pour executer plusieurs instances, il faut modifier le port d'écouter smtp et http dans le fichier init.d :

Exemple:

cp /etc/init.d/mailcatcher /etc/init.d/mailcatcher-galilea

puis spécifier le nouveau port dans la commande de lancement (vérifier les ports en écoute avec un netstat -plnt)

case "$1" in
 start)
   su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0 --smtp-port 1026 --http-port 1081'
   ;;
 stop)
   killall mailcatcher
   sleep 5
   ;;
 restart)
   killall mailcatcher
   sleep 5
   su mailcatcher -c 'mailcatcher --http-ip 0.0.0.0 --smtp-port 1026 --http-port 1081'
   ;;
 *)
Attention tout stop/redémarrage du service stoppera toutes les instances mailcatcher présentes sur le serveur (présence du killall) !!!!

[modifier] Installation d'un certificat auto-signé pour la preprod (si besoin)

openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout preprod.redlink.hegyd.net.key -out preprod.redlink.hegyd.net.crt

Ajout du vhost dans le fichier de conf apache :

<VirtualHost *:443>
        DocumentRoot /var/projects/redlink/preprod/public
        ServerName preprod.redlink.hegyd.net
        ServerAlias *.preprod.redlink.hegyd.net
        SetEnv APPLICATION_ENV preproduction
        SSLENgine On
        SSLCertificateFile  /etc/ssl/preprod.redlink.hegyd.net/preprod.redlink.hegyd.net.crt
        SSLCertificateKeyFile /etc/ssl/preprod.redlink.hegyd.net/preprod.redlink.hegyd.net.key

        Alias /media /var/projects/redlink/preprod/storage
        <directory /var/projects/redlink/preprod/storage>
            options indexes followsymlinks
            order allow,deny
            allow from all
        </directory>
</VirtualHost>