Symfony 2 hosting server

 Screenshot from 2013-10-08 12:34:07Symfony again! Hello, as you know I like to hit my head against the screen from time to time. So today I’m going to try to configure a server to host Symfony Aplications. The host in this case will be a virtual machine in my own computer.

Note: this post is about how to install Symfony, how to meet the requirements. if you have done this already maybe what you need is to deploy your product app. visit this link for that . And if you want to install in windows you can follow this link

My OS is a Debian testing (8) and I have a virtualbox running ready to have a lot of virtual
machines. So I have created a Debian Stable (7) Virtual Machine that will be our server for the symfony 2 applications. in this case I’m going to use Symfony 2.3.5 the latest version available on the server. I am talking to much take a look at the image of my of my VM for more information.

Symfony is based on PHP so the basics requirements, but not the only ones are PHP (5.2.x or superior), we will also use Apache but you can user any other thing or even the built in server that comes with Symfony. and the rest of the application requirements like MySQL or Postgres is is the case. Any way the requirements for Symfony are this:

Required
  • PHP needs to be a minimum version of PHP 5.3.3
  • JSON needs to be enabled
  • ctype needs to be enabled
  • Your PHP.ini needs to have the date.timezone setting
Optional
  • You need to have the PHP-XML module installed
  • You need to have at least version 2.6.21 of libxml
  • PHP tokenizer needs to be enabled
  • mbstring functions need to be enabled
  • iconv needs to be enabled
  • POSIX needs to be enabled (only on *nix)
  • Intl needs to be installed with ICU 4+
  • APC 3.0.17+ (or another opcode cache needs to be installed)
  • PHP.ini recommended settings
    • short_open_tag = Off
    • magic_quotes_gpc = Off
    • register_globals = Off
    • session.auto_start = Off

 

Taken from the official Current web site. Otherwise to check the requirements they have a comand that works:

php app/check.php

Besides you can also go to your localhost/Symfony-folder-to-deploy/web/config.php, but I have no graphics in the server, so we use the command.

when you run the command it will tell you a few things:

root@khs01sw06:/var/Symfony# php app/check.php
********************************
* *
* Symfony requirements check *
* *
********************************
* Configuration file used by PHP: /etc/php5/cli/php.ini
** ATTENTION **
* The PHP CLI can use a different php.ini file
* than the one used with your web server.
* To be on the safe side, please also launch the requirements check
* from your web server using the web/config.php script.
** Mandatory requirements **
OK PHP version must be at least 5.3.3 (5.4.4-14+deb7u4 installed)
 OK PHP version must not be 5.3.16 as Symfony won't work properly with it
 OK Vendor libraries must be installed
 OK app/cache/ directory must be writable
 OK app/logs/ directory must be writable
 ERROR date.timezone setting must be set
 Set the "date.timezone" setting in php.ini* (like Europe/Paris).
OK Configured default timezone "Africa/Khartoum" must be supported by your installation of PHP
 OK json_encode() must be available
 OK session_start() must be available
 OK ctype_alpha() must be available
 OK token_get_all() must be available
 OK simplexml_import_dom() must be available
 OK APC version must be at least 3.1.13 when using PHP 5.4
 OK detect_unicode must be disabled in php.ini
 OK PCRE extension must be available
** Optional recommendations **
OK Requirements file should be up-to-date
 OK You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions
 OK When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156
 OK You should not use PHP 5.4.0 due to the PHP bug #61453
 WARNING When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)
 Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.
WARNING You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909
 Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.
OK PCRE extension should be at least version 8.0 (8.3 installed)
 OK PHP-XML module should be installed
 OK mb_strlen() should be available
 OK iconv() should be available
 OK utf8_decode() should be available
 OK posix_isatty() should be available
 WARNING intl extension should be available
 Install and enable the intl extension (used for validators).
OK a PHP accelerator should be installed
 WARNING short_open_tag should be disabled in php.ini
 Set short_open_tag to off in php.ini*.
OK magic_quotes_gpc should be disabled in php.ini
 OK register_globals should be disabled in php.ini
 OK session.auto_start should be disabled in php.ini
 OK PDO should be installed
 OK PDO should have some drivers installed (currently available: mysql)
root@khs01sw06:/var/Symfony#

As you might have already notices there is at least one error in my config to deploy Symfony. The time zone is not properly set… I mean not fixed. We have to change that in order to make Symfony work, but the point that I want you to get is that this command is very helpful, because it says what is pending. for instance now I would change the timezone.

root@khs01sw06:/var/Symfony# php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-apc.ini,
/etc/php5/cli/conf.d/20-curl.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-ldap.ini,
/etc/php5/cli/conf.d/20-mcrypt.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini
root@khs01sw06:/var/Symfony# nano /etc/php5/cli/php.ini (Here is where we edit our PHP.ini files, we have to edit the one for apache2 also if we are going to use it, in my case I have to set it to something like this in the php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Africa/Gaborone

)
root@khs01sw06:/var/Symfony# service apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
root@khs01sw06:/var/Symfony#

Now when you check again the result should be different:

** Mandatory requirements **
OK PHP version must be at least 5.3.3 (5.4.4-14+deb7u4 installed)
 OK PHP version must not be 5.3.16 as Symfony won't work properly with it
 OK Vendor libraries must be installed
 OK app/cache/ directory must be writable
 OK app/logs/ directory must be writable
 OK date.timezone setting must be set
 OK Configured default timezone "Africa/Gaborone" must be supported by your installation of PHP

Then we shall continue solving the rest of the pending issues:

WARNING When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)
 Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.
WARNING You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909
 Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.

 

It says that My PHP version is not good for somethings…  that is because Debian is always behind in the stable version, so we might need to re-install it, but any way is just a warning, not an error.

root@khs01sw06:/var/Symfony# php -v
PHP 5.4.4-14+deb7u4 (cli) (built: Aug 26 2013 07:40:51) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
root@khs01sw06:/var/Symfony#

After we configure the requirements depending on our needs we just have to configure the application to install depending on it’s own needs and the web server is READY. cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *