Linode Library Home
Linode Library RSS Feed
Home :: Frameworks
Print View View Source

Symfony on CentOS 5

Published: by


This document is an older, unmaintained guide. There may be a new guide available for this software.

Symfony is a PHP web application framework, providing the classes and tools required to build and enhance both simple and complex applications. Featuring easy AJAX integration, an admin interface generator, and more, Symfony has become a very popular choice for web application development.

Before installing Symfony, it is assumed that you have followed our getting started guide. If you're new to Linux server administration, you may be interested in our using Linux document series, including the beginner's guide and administration basics guide.


Basic System Configuration

First, update all of the base packages:

yum update

Install make, as it will be required for installation of the other packages:

yum install make

Since CentOS does not include the latest version of PHP 5.2 (which is required for the Symfony Framework), you'll need to add an external repository. Add the webtatic repository:

rpm -ivh`uname -i`/webtatic-release-5-0.noarch.rpm

Edit the file /etc/yum.repos.d/webtatic.repo. Under [webtatic] add the following line:

File excerpt:/etc/yum.repos.d/webtatic.repo


This will ensure that no PHP 5.3 packages will be installed, as Symfony does not use any features of PHP 5.3.

Install Required Packages

Install the Apache web server with devel package:

yum --enablerepo=webtatic install httpd httpd-devel

Install the MySQL database server:

yum --enablerepo=webtatic install mysql mysql-server

Install PHP 5.2 with the packages required for the Symfony:

yum --enablerepo=webtatic install php php-mysql php-pear php-devel php-xml php-posix php-mbstring

Install the compiler packages, as we will need them for the installation of the APC accelerator:

yum install gcc

Install the APC accelerator using PECL:

pecl install apc

Answer "yes" to all questions. After the installation complete, execute the following command to add the APC module to the web server:

echo > /etc/php.d/apc.ini

Set the MySQL server to start on boot and start it:

/sbin/chkconfig --levels 235 mysqld on
service mysqld start

Set the root password for the MySQL server and apply the security necessities:


Edit /etc/php.ini and find the following line:

File excerpt:/etc/php.ini

short_open_tag = On

Replace it with this line:

File excerpt:/etc/php.ini

short_open_tag = Off

Set the web server to start on boot and start it:

/sbin/chkconfig --levels 235 httpd on
service httpd start

Download the Symfony system configuration check file and run it:

php check_configuration.php

You should get "OK" for all the tests.

Create Your First Symfony Project

Create a project folder under /home. We will use sfproject as our project name:

mkdir /home/sfproject
cd /home/sfproject

Create lib/vendor folder under the /home/sfproject:

mkdir -p lib/vendor
cd lib/vendor

Download the latest Symfony release:


Extract it and rename it:

tar zxpf symfony-1.4.5.tgz
rm symfony-1.4.5.tgz
mv symfony-1.4.5 symfony

Go to the project root and generate the project:

cd /home/sfproject
php lib/vendor/symfony/data/bin/symfony generate:project sfproject

Now, Symfony has created all necessary files/folders for the project. You can have a look at them.

There is now a symfony executable shortcut under /home/sfproject. From now on you can use the ./symfony shortcut (when you are in the /home/sfproject directory) to execute Symfony commands.

Configure the database, entering your MySQL root password for "pass":

./symfony configure:database "mysql:host=localhost;dbname=dbname" root pass

Generate the frontend application:

./symfony generate:app frontend

Now, we need to configure the web server to serve our new project.

Edit /etc/httpd/conf/httpd.conf and add at the end:

File excerpt:/etc/httpd/conf/httpd.conf

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot "/home/sfproject/web"
  DirectoryIndex index.php
  <Directory "/home/sfproject/web">
    AllowOverride All
    Allow from All

  Alias /sf /home/sfproject/lib/vendor/symfony/data/web/sf
  <Directory "/home/sfproject/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All

Restart the web server:

service httpd restart

Using your browser, browse to your Linode's IP address. You should now see the Symfony Project Created page. From now on, you can easily follow the official Symfony tutorial.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

Creative Commons License

This guide is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.

Last edited by Sharon Campbell on Friday, September 27th, 2013 (r3728).