Skip to content

How to run your Symfony application on Ubuntu Xenial

April 25, 2016Maxime Thoonsen2 min read

This article explains the differences I found between Trusty and Xenial to run a Symfony application.

So what's new in the latest Ubuntu LTS release? On the application side we have:

  • PHP 7.0
  • Nginx 1.9.15
  • Python 3.5
  • Postgresql 9.5
  • Mysql 5.7.11
  • Mongo 2.6.10
  • Docker 1.10

From Trusty to Xenial

My goal was to run the default project from the Symfony installer on a Vagrant VM. I also wanted to be able to use Mysql, Postgresql or Mongodb.
I explain below, all the steps I needed to do so.

First I ran: symfony new xenial64 to quickly get all the Symfony files.
Then I looked for the official Vagrant box of Xenial and found it here.
My next step was using my Ansible playbook generator to get the first draft of provisioning.

I updated the Vagrantfile to use the right Vagrant box and I ran vagrant up. Unfortunately, an error occurred and I wasn't the only one.

As I didn't want to wait for the next release of Vagrant, I moved away from the official box to an unofficial one. It worked without any error this time.

I then launched the provisioning with ansible-playbook devops/provisioning/playbook.yml -i devops/provisioning/hosts/vagrant and met my first errors during the PHP role.

Changes related to PHP.

I needed to update the role as we are now using PHP 7.
I manually installed all the PHP packages needed, as I didn't know their name.

Here is a short list:

- php
- php7.0-mysql
- php7.0-pgsql
- php7.0-mcrypt
- php7.0-curl
- php7.0-dev
- php7.0-gd
- php7.0-ldap
- php7.0-sqlite3
- php7.0-intl
- php-apcu

Note that the PHP conf files have also slightly changed their location from /etc/php5 to /etc/php/7.0.

Symfony3 requirements

Changes related to Nginx

Everything went well except that the php-fpm socket has changed from /var/run/php5-fpm.sock to /var/run/php/php7.0-fpm.sock.

Changes related to Mongodb

Things are now much simpler than before because of a apt-get install mongodb is now enough to install Mongodb.

Postgresql

No problem =)

Mysql

I had one issue with the /etc/mysql/my.cnf configuration file. It has been split into different files so it's a little bit harder to set the right configuration. Otherwise, everything was OK.

Conclusion

And this is it, if you want to try by yourself everything is here.
Symfony3 xenial
You will find a Vagrantfile, an Ansible provisioning, and the Symfony files.

If you want to know more about Xenial, here are some useful links:

Don't hesitate to share with us the best links you found. If you have questions, you can ask me on twitter.