Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8377985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:48:53+00:00 2026-06-09T15:48:53+00:00

Ngigx + PHP-FPM setup and working in root-directory, but I’m having trouble getting virtual

  • 0

Ngigx + PHP-FPM setup and working in root-directory, but I’m having trouble getting virtual directories to work.

I want //localhost/pb/test.php to execute c:\opt\php\public\test.php but it breaks with “no input file specified”. In fact, not even .html files works, but once working, I want the php-directive to work under /pb as well.

current nginx.conf:

server {
    listen       80;
    server_name  localhost;

    location / {
        root   html;
        index  index.html index.htm index.php;
    }

location /pb/ {
    root   /opt/php/public;
        index  index.html index.htm index.php;
}

location ~ \.php$ {
        fastcgi_pass    127.0.0.1:9123;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include         fastcgi_params;
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:48:55+00:00Added an answer on June 9, 2026 at 3:48 pm

    http://nginx.org/en/docs/http/ngx_http_core_module.html#location explains how nginx matches locations.
    in this case your prefix location /pb/ will match, and nginx will never get to the *.php matching location

    what I would try is to set up a named location (the @bit makes it a named location):

    location @fastcgi {
      fastcgi_pass    127.0.0.1:9123;
      fastcgi_index   index.php;
      fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include fastcgi_params;
    }
    

    and then refer to that in try_files directives from other locations, like this:

    location /pb/ {
      root   /opt/php/public;
      index  index.html index.html;
      try_files $uri @fastcgi;
    } 
    
    location ~ \.php$ {
      alias @fastcgi;
    }
    

    the try files above would first try an exact match file name and if it doesn’t find that it will pass the request to the @fastcgi location

    alternatively you could offcourse simply repeat the fastcgi bits in a nested location block inside your /pb/ location

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a PHP-fpm setup on nginx setup according to this article: http://interfacelab.com/nginx-php-fpm-apc-awesome/ PHP
I'm building a simple server setup for developping purposes, with Nginx, PHP-FPM, APC, Varnish
I have two websites running on my own root server (ubuntu/nginx/php-fpm). Now I want
I have my moodle setup using this guide ( Ubuntu 11.04 ) http://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm I
Original question I met a strange problem with nginx + php-fpm. If my root
I'm in the process of moving a working apache/mod-php website to nginx/php-fpm. Under Apache/mod-php,
Trying to install Symfony 1.4.11 application on Ubutnu Server + Nginx + php-fpm Nginx
I have 4 webservers behind cloudflare and a loadbalancer, nginx is the webserver, php-fpm
I'm attempting to set up the Laravel PHP Framework to work with Nginx .
I run a virtual copy of Debian on VirtualBox to develop a larger-sized PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.