在nginx配置下执行php脚本

I have the following nginx server block in its configuration

server {
    listen       80;
    server_name mydomain.com;
    location /deploy {
        alias /home/somedir/deploy/;
        }

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

    }
  }

I want to execute a php file at the url mydomain.com/deploy/erp/index.php or mydomain.com/deploy/erp

The above thing downloads the php file instead of executing it. I googled and found solutions that asks you to define a www directory or something. I just need to execute the file in a specific directory at specific url. What are my options?

You haven't told nginx what to do with .php files. Assuming you're using php-fpm, you'll need something like this:

server {
  listen       80;
  server_name mydomain.com;

  root /home/somedir;

  location / {
    try_files $uri $uri/ =404;
  }

  location /deploy {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
  }
}