Nginx, PHP-FPM with 2 apps in subfoders

You have two PHP apps, hosted in different document roots, which means that you need two location ~ \.php$ blocks. Assuming that SOMENAME and somename are actually the same, you can use something like this:

root /www/main;
index index.html index.php;

location / {
    try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass  unix:/var/run/php5-fpm.sock;
    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
}

location ^~ /somename {
    root /www;
    try_files $uri $uri/ /somename/index.php;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass  unix:/var/run/php5-fpm.sock;
        include       fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
    }
}

The ^~ modifier on the location directive, make this prefix location take precedence over the regular expression location block above it, so that PHP scripts are processed by the correct location block. See this document for details.

The try_files directive is documented here.