Artisan Développeur

Qualité, amélioration continue, agilité.

Vagrant debian Stretch 9.4 for Symfony dev

I choose to have a parent directory for my vagrant projects, -p or –parents tells mkdir to create all the needed parent folders.

mkdir -p vagrant/myproject
cd vagrant/myproject

vagrant init

vagrant init
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`` for more information on using Vagrant.

Edit Vagrantfile:

In the Vagrantfile you have this by default: = "base"

edit to use the box you choose, I choose this one

info: mainpage of debian boxes = "debian/stretch64"

vagrant up

vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'debian/stretch64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'debian/stretch64'
    default: URL:
==> default: Adding box 'debian/stretch64' (v9.4.0) for provider: virtualbox
    default: Downloading:
==> default: Successfully added box 'debian/stretch64' (v9.4.0) for 'virtualbox'!
==> default: Importing base box 'debian/stretch64'...                                                                                
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'debian/stretch64' is up to date...                                                                     
==> default: Setting the name of the VM: myproject_default_1523353141366_70143                                                       
==> default: Clearing any previously set network interfaces...                                                                       
==> default: Preparing network interfaces based on configuration...                                                                  
    default: Adapter 1: nat                                                                                                          
==> default: Forwarding ports...                                                                                                     
    default: 22 (guest) => 2222 (host) (adapter 1)                                                                                   
==> default: Running 'pre-boot' VM customizations...                                                                                 
==> default: Booting VM...                                                                                                           
==> default: Waiting for machine to boot. This may take a few minutes...                                                             
    default: SSH address:                                                                                             
    default: SSH username: vagrant                                                                                                   
    default: SSH auth method: private key                                                                                            
    default: Vagrant insecure key detected. Vagrant will automatically replace                                                       
    default: this with a newly generated keypair for better security.                                                                
    default: Inserting generated public key within guest...                                                                          
    default: Removing insecure key from the guest if it's present...                                                                 
    default: Key inserted! Disconnecting and reconnecting using new SSH key...                                                       
==> default: Machine booted and ready!                                                                                               
==> default: Checking for guest additions in VM...                                                                                   
    default: No guest additions were detected on the base box for this VM! Guest                                                     
    default: additions are required for forwarded ports, shared folders, host only                                                   
    default: networking, and more. If SSH fails on this machine, please install                                                      
    default: the guest additions and repackage the box to continue.                                                                  
    default: This is not an error message; everything may continue to work properly,                                                                                                                                                                                           
    default: in which case you may ignore this message.                                                                                                                                                                                                                        
==> default: Installing rsync to the VM...                                                                                                                                                                                                                                     
==> default: Rsyncing folder: /var/www/myfolder/vagrant/myproject/ => /vagrant

==> default: Machine 'default' has a post `vagrant up` message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default: 
==> default: Vanilla Debian box. See for help and bug reports
  • « vagrant ssh » to log in your new virtual machine
  • « exit » to logout
  • « vagrant destroy » to stop the virtual machine


install php 7.1 on debian 9.4

Hi !

Here the solution that has work for me, I found others tutorials but I had to execute a few more step to complete the setup as I want.

First, the repository, thanks to, the readme file is here

Based on that:

wget -O /etc/apt/trusted.gpg.d/php.gpg

sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

apt-get update

As a precision, the link for the lsb_release command man page, it is useful to get the name of your current distribution, try it on a terminal:

lsb_release -sc

In my case, I only want one PHP version, I don’t want to keep the 7.0, I just want have the 7.1 as default, to do that you need to install the new, remove the old without forgetting the apache module.

apt-get install php7.1
apt-get remove php7.0

apt-get remove libapache2-mod-php7.0

The php7.1 module is already installed as dependency of php7.1.

And if you need it you can do

dpkg-reconfigure libapache2-mod-php7.1

Now you have php7.1 running 😉

You may want to clean more for production, but I do not cover this here, I do this on my dev env


Don’t miss 500 internal error anymore with symfony and monolog

Sometimes I read my server logs … Like some people read the newspaper, in fact server logs are like the app newspaper 🙂

Every morning I am reading my logwatch email.

But I can miss errors, and even if I see them, it is the next day in my logs email, and it is really BAD

The solution is simple, use monolog to send you errors directly

My configuration is (config_prod.yml):

            type:   stream
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  error
            type:         fingers_crossed
            # 500 errors are logged at the critical level
            action_level: critical
             handler:      deduplicated
            type:    deduplication
            handler: swift
            type:       swift_mailer
            from_email: 'email@myserv.myserv'
            to_email:   'mymorningemail@myserv.myserv'
            subject:    'You have to work ! An Error Occurred! %%message%%'
            level:      debug
            formatter:  monolog.formatter.html
            content_type: text/html