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 https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
Create a root directory for your project and clone Silex-Skeleton
mkdir -p /var/www/yourwebsite.dev/{public_html,logs} cd /var/www/yourwebsite.dev/public_html
Clone the repo
git clone https://github.com/silexphp/Silex-Skeleton.git .
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/yourwebsite.dev/public_html/var/cache/
Nginx configuration.
Create a new Nginx server block with the following content
# /etc/nginx/sites-available/yourwebsite.dev server { server_name yourwebsite.dev; listen 80; root /var/www/yourwebsite.dev/public_html; access_log /var/www/yourwebsite.dev/logs/access.log; error_log /var/www/yourwebsite.dev/logs/error.log; 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/yourwebsite.dev /etc/nginx/sites-enabled/yourwebsite.dev /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.