Mounting a remote filesystem using sshfs

It seems few people know that you can easily mount a remote filesystem over an ssh connection, using the pretty obviously named tool “sshfs”. It’s pretty buggy on Windows, but it works like a charm on OSX and Linux. You do need a stable network connection to keep the connection working fast though.


# Homebrew
brew install sshfs

# Ubuntu
sudo apt-get install sshfs

# CentOS
sudo yum install ssfs

Aliases in .bash_profile

I use aliases for most of my ssh connections and sshfs mounts. Combined with using my ssh key (with extra password) this gives me an almost instant login to servers by typing a simple alias for it.

# ~/.bash_profile
# Options for ssh and sshfs aliases
# These have been proven to be the best ones for Mac OSX so far
SSHOPTS='-v -4'

# ssh connection aliases
alias server01="ssh $SSHOPTS"

# sshfs mounts
alias fsserver01="sshfs $SSHFSOPTS -ovolname=server01 \
  karel@server01.local:/var/www/vhosts/ \

Using an sshfs mount to work

With these aliases in place I would start working like this:

# 1. Mount the remote file system

# 2. Open $HOME/Projects/ in my local editor

# 3. Login to the server to run my git commands etc:


A side note after using these kind of setups for almost 3 years: you need a very fast and reliable internet connection to make this work.

Also funky editors like PHPStorm and Eclipse cannot handle working on a mount like this (they perform a lot of directory and file scanning to discover things), but it works perfectly with Sublime Text 3.

A safer nginx virtual host config for Symfony2 sites

As Symonfy redirects all PHP requests to app.php, it’s a safe solution to only use app.php as your nginx fastcgi_pass script. This way it’s simply impossible to run PHP code from other files (e.g. malware that tries to inject code into your site).

Your webroot would still point to Symonfy’s web directory.


server {
  listen 80;
  root /var/www/vhosts/;
  index index.php index.html;
  location / {
    try_files $uri @app;
  location @app {

    fastcgi_pass unix:/var/run/php5-fpm.sock;

    include fastcgi_params;

    fastcgi_param SCRIPT_FILENAME /var/www/vhosts/;
    fastcgi_param SCRIPT_NAME /var/www/vhosts/;



Unlike a common PHP setup for nginx, there is no location match for *.php files now.

This setup can also be applied to Drupal’s setup, as Drupal does the same thing with the index.php file in the document root.

This information was taken from Gerry Vandermaesen’s The Unofficial ‘Best’ Practises on Symfony development.