Install Silex on Debian Wheezy


In this article we will show you how to install Silex via composer on Debian Wheezy VPS with PHP-FPM and Nginx .  Silex is a PHP micro-framework based on the Symfony2 Components and Pimple. Silex is an open source product licensed under a MIT License and developed by Fabien Potencier, the creator of the Symfony framework.


Install Nginx and PHP-FPM and Git

apt-get install nginx php5-fpm php5-cli php5-gd php5-mcrypt git

Install Composer (tool for dependency management in PHP

curl -sS | php
mv composer.phar /usr/local/bin/composer

Create a root directory for your project and clone Silex-Skeleton

mkdir -p /var/www/{public_html,logs}
cd /var/www/

Clone the repo

git clone .

and run

composer install

to install all dependencies.

Run the following command to change the ownership of the cache directory

chown -R www-data: /var/www/

Nginx configuration.

Create a new Nginx server block with the following content

# /etc/nginx/sites-available/
server {
  listen 80;
  root /var/www/;
  access_log /var/www/;
  error_log /var/www/;
  index index.html index.php;
  location / {
    try_files $uri $uri/ @rewrites;
  location @rewrites {
    #rewrite ^ /index.php last;
    rewrite ^/(.*)$ /index.php?url=$1 last;
  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  location ~ /\.ht {
    deny  all;
  location ~ \.php {
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Symlink it and restart the server

ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
/etc/init.d/nginx restart

Finally, open your browser and navigate to your domain. If everything goes well, you should see something similar to this:

Welcome to your new Silex Application!

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services in which case you can simply ask our expert Linux admins to install this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment

To prove you are human please solve the following *