Install Symfony on Debian 4.0 Etch
Symfony is a powerful PHP 5 framework that ease development of PHP applications. This article help you to install Symfony on Debian 4.0 Etch.
First, you need to login as the root user. This can be done by using this command :
su -
Install of needed packages
The first step is to install a GLDAP environment (GNU / Linux Debian - Apache 2 - PHP). In order to achieve this, run this command line :
apt-get install libapache2-mod-php5 php-pear php5-mysql php5-cli php5-xsl
Don't forget to enable the Apache 2 rewrite module :
a2enmod rewrite
To install Symfony, you need to rise the memory limit for the PHP command line interpreter :
sed -i -e 's/memory_limit = .*/memory_limit = 32M/' /etc/php5/cli/php.ini
You also need to rise the memory limit for the PHP module of Apache 2 :
sed -i -e 's/memory_limit = .*/memory_limit = 128M/' /etc/php5/apache2/php.ini
Then you need to disable the PHP magic quotes option :
sed -i -e 's/magic_quotes_gpc = .*/magic_quotes_gpc = Off/' /etc/php5/apache2/php.ini
Installing Symfony
Before installing Symfony, you need to upgrade PEAR. This can be done by running these command lines :
pear channel-update pear.php.net
pear upgrade PEAR
You can now install Symfony. In order to do this, register the Symfony chanel into your PEAR configuration :
pear channel-discover pear.symfony-project.com
Now, we download and install Symfony :
pear install symfony/symfony
Then, we install phing (I don't know if it is really needed) :
pear channel-discover pear.phing.info
pear config-set preferred_state beta
pear install --alldeps phing/phing
Note : If you want to be able to generate automatic documentation, you need to install PhpDocumentor :
pear install PhpDocumentor XML_Beautifier
Now, check that Symfony is installed :
symfony -V
If this command line work, you have now a working installation of the Symfony framework. The last thing to do is to create a place where coding your projects :
mkdir /home/sfprojects
chgrp users /home/sfprojects
chmod ugo+w /home/sfprojects
Symfony project creation
For the example, we create a new Symfony project. You can do this with your usual user. First, choose a name for your project :
SYMFONY_PROJECT=askeet
Then create it :
mkdir /home/sfprojects/$SYMFONY_PROJECT
cd /home/sfprojects/$SYMFONY_PROJECT
symfony init-project $SYMFONY_PROJECT
Once the project created, we can create applications, In order to achieve this, choose the name of your application :
SYMFONY_APP=frontend
And create it :
cd /home/sfprojects/$SYMFONY_PROJECT
symfony init-app $SYMFONY_APP
Now, we create a associated Apache 2 web site :
su -c "echo '<VirtualHost *>
ServerName $SYMFONY_PROJECT
DocumentRoot \"/home/sfprojects/$SYMFONY_PROJECT/web\"
Alias /sf /usr/share/php/data/symfony/web/sf
<Directory \"/home/sfprojects/$SYMFONY_PROJECT/web\">
AllowOverride All
</Directory>
</VirtualHost>' \
> /etc/apache2/sites-available/$SYMFONY_PROJECT"
Don't forget to enable it :
su -c "a2ensite $SYMFONY_PROJECT"
Check you Apache 2 configuration :
su -c "apache2ctl -t"
If it is allright, reload the Apache 2 configuration :
su -c "/etc/init.d/apache2 reload"
Now, we add a line to our hosts file in order to access easily to our project :
su -c "echo '127.0.0.1 $SYMFONY_PROJECT' >> /etc/hosts"
You can now start to work on your Symfony project. Use this command line to open it in your browser :
firefox http://$SYMFONY_PROJECT
What's next
Now that you have installed it, i encourage you to follow this 24 tutorials to learn the use of Symfony.
Upgrading Symfony
If you want to upgrade Symfony, use these command lines as a super user :
pear channel-update pear.php.net
pear upgrade --alldeps PEAR
pear channel-update pear.symfony-project.com
pear upgrade symfony/symfony
You can also upgrade all PEAR packages :
pear update-channels
pear upgrade-all
Now, for each Symfony project available on your computer, run (if necessary) :
symfony upgrade version.de.symfony
Generating documentation
If you have installed PhpDocumentor, you can generate your project documentation by using the command line :
phpdoc -d /home/sfprojects/$SYMFONY_PROJECT -t /home/sfprojects/$SYMFONY_PROJECT/doc
Thanks
- Thanks to Niko for his article Installer le framework PHP Symfony sur Ubuntu Dapper Drake.
Greate guide