首页 > nginx > nginx 多个虚拟主机 no input file specified

nginx 多个虚拟主机 no input file specified

2010年4月19日 eric 发表评论 阅读评论

今天配置nginx rewrite 的时候遇到一个问题,就是访问服务器的是时候提示 No input file specified.访问PHP,访问php就没有事,可以正常访问。猜想可能是php-cgi的问题吧,google 了一下,果然问题出现在这里。

网上提供的解决方法:

1、 php.ini(/usr/local/php/etc/php.ini)的配置中这两项
cgi.fix_pathinfo=1  (这个是自己添加的)
doc_root=

 2、nginx配置文件/usr/local/nginx/conf/nginx.conf 中注意以下部分
location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /var/www/www.abc.com/$fastcgi_script_name;
                include               fastcgi_params;
        }

红字部分是虚拟主机的根目录。然后重启 php-fpm 和nginx

 我只实践了第二种方法,方法如下:

为 abc.com 创建一个 fastcgi_params 配置文件

vim /usr/local/nginx/conf/abc_fcgi.conf

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;

fastcgi_param  SERVER_SOFTWARE    nginx;

fastcgi_param  QUERY_STRING       $query_string;

fastcgi_param  REQUEST_METHOD     $request_method;

fastcgi_param  CONTENT_TYPE       $content_type;

fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    /var/www/www.abc.com/$fastcgi_script_name;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

fastcgi_param  REQUEST_URI        $request_uri;

fastcgi_param  DOCUMENT_URI       $document_uri;

fastcgi_param  DOCUMENT_ROOT      $document_root;

fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  REMOTE_ADDR        $remote_addr;

fastcgi_param  REMOTE_PORT        $remote_port;

fastcgi_param  SERVER_ADDR        $server_addr;

fastcgi_param  SERVER_PORT        $server_port;

fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi_param  REDIRECT_STATUS    200;

红色部分根据自己需要添加。

abc.com   虚拟主机配置文件

vim /usr/local/nginx/conf/abc.conf

server

  {

     listen      80;

     server_name  abc.com  www.abc.com;

     index index.html index.htm index.php;

     root  /var/www/www.abc.com;

     include /var/www/www.abc.com/.htaccess;

    location ~ .*\.(php|php5)?$

    {

          #fastcgi_pass  unix:/tmp/php-cgi.sock;

          fastcgi_pass  127.0.0.1:9000;

          fastcgi_index index.php;

         include abc_fcgi.conf;

     }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

   {

        expires      30d;

   }

   location ~ .*\.(js|css)?$

   {

      expires      1h;

   }

   error_page  404  =  /404.gif;

   log_format  88  '$remote_addr - $remote_user [$time_local] "$request" '

                     '$status $body_bytes_sent "$http_referer" '

                     '"$http_user_agent" $http_x_forwarded_for';

   access_log  logs/88_log  88;

}

其实还有一种解决办法就是很浪费资源,就是拷贝多个 php-fpm.conf 文件,每个域名一个,开启不同的端口,每个配置文件都要添加不同的目录.

例如 abc.com  123.com 两个站点

cp /usr/local/php/etc/php-fpm.conf  /usr/local/php/etc/abc.com.conf

cp /usr/local/php/etc/php-fpm.conf  /usr/local/php/etc/123.com.conf

先修改 abc.com 虚拟主机

找到php_defines,在下面添加

<value name="open_basedir">/var/www/www.abc.com:/tmp:/var/tmp</value>

然后修改端口

<value name="listen_address">127.0.0.1:9001</value>

修改 123.com 虚拟主机

找到php_defines,在下面添加

<value name="open_basedir">/var/www/www.123.com:/tmp:/var/tmp</value>

然后修改端口

<value name="listen_address">127.0.0.1:9002</value>

 最后修改启动脚本:

vim /usr/local/php/sbin/php-fpm

注释掉原来的 #$php_fpm_BIN –fpm $php_opts,田间

 $php_fpm_BIN --fpm --fpm-config /usr/local/php/etc/www.abc.com.conf

 $php_fpm_BIN --fpm --fpm-config /usr/local/php/etc/www.123.com.conf

 启动服务

 #/usr/local/php/sbin/php-fpm restart

 修改  nginx.conf 不同的虚拟主机对应不同的 php-fpm 端口,这样就不会造成No input file specified

转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/125.html

分类: nginx 标签: , ,
  1. 2017年10月29日02:49 | #1

    Hello There. I found your blog using msn. This is a very well written article.
    I’ll be sure to bookmark it and return to read more of your useful information. Thanks
    for the post. I will certainly return.

  2. 2017年10月29日05:45 | #2

    Do you mind if I quote a couple of your posts as long
    as I provide credit and sources back to your site? My blog
    is in the exact same niche as yours and my visitors would really benefit from some of the
    information you present here. Please let me know if this okay
    with you. Many thanks!

  3. 2017年10月29日12:18 | #3

    I loved as much as you will receive carried out right
    here. The sketch is attractive, your authored material stylish.
    nonetheless, you command get got an impatience over that you wish be delivering the following.
    unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you shield this increase.

  4. 2017年10月30日20:03 | #4

    Greetings! Very useful advice in this particular article!

    It is the little changes that will make the largest changes.

    Thanks a lot for sharing!

  5. 2017年11月1日07:46 | #5

    Thankfulness to my father who shared with me concerning this web site,
    this website is truly awesome.

  6. 2017年11月2日17:08 | #6

    I do trust all of the ideas you have presented for your post.

    They’re really convincing and can certainly work. Still, the posts are too brief for newbies.
    May just you please extend them a bit from next time? Thanks for the post.

  7. 2017年11月3日02:56 | #7

    cheap cialis sale online
    cheap viagra
    cialis rush order

  8. 2017年11月3日19:13 | #8

    Great article! This is the kind of information that
    are supposed to be shared across the net. Shame on Google for now not positioning
    this post upper! Come on over and discuss with my website
    . Thank you =)

  9. 2017年11月4日02:51 | #9

    hello there and thank you for your information – I’ve definitely
    picked up anything new from right here. I did however
    expertise a few technical issues using this site, since I experienced to reload the web site lots
    of times previous to I could get it to load correctly. I had been wondering if your hosting
    is OK? Not that I’m complaining, but slow loading instances
    times will very frequently affect your placement in google and can damage your quality score if ads and marketing with Adwords.
    Anyway I am adding this RSS to my e-mail
    and could look out for a lot more of your respective interesting content.
    Make sure you update this again soon.

  10. 2017年11月4日10:26 | #10

    Tremendous issues here. I’m very satisfied to look your article.
    Thanks so much and I am having a look ahead to contact you.
    Will you please drop me a e-mail?

  11. 2017年11月5日17:01 | #11

    Link exchange is nothing else except it is simply placing the other person’s website link on your page at suitable place and other person will also do similar in support of you.

  12. 2017年11月6日22:30 | #12

    Link exchange is nothing else but it is only placing the other person’s blog link
    on your page at proper place and other person will also do
    similar for you.

  13. 2017年11月8日04:03 | #13

    15年度の運用損失が響き、01~15年度の累計の運用益は45兆4239億円(14年度末は50兆7338億円)と5年ぶりに縮小。 Windows のインストールとして認識された合計数:1インストールをブート一覧に追加しますか? Yes(Y)/No(N)/All(A):Y操作は正常に終了しました。 [url=http://www.key7jp.com/windows-8-1-enterprise-x64-4.html]windows8 セットアップ[/url]
    ・管理者のアドバイスに拠りウイルスチェッカを切って貰った。 70-334受験料:現行価格で70-334受験するには19000円です。
    [url=http://www.key7jp.com/category-3-b0-Adobe.html]Adobe 購入[/url] 試験を受ける予定があれば、急いでPass4Testへ来て必要な情報を見つけましょう。 ついてないと思ってふと見たら写真のようにメグ(Meg)の隣にバロック喫茶があったのでそこで休みました。
    [url=http://www.key7jp.com/windows-10-47.html]windows8 1 ダウンロード[/url]
    このOsloとOffice Graphを紹介したプレゼンテーションがChannel 9で、概要を紹介したものがOffice Blogでそれぞれ参照できる。 まるで、量販店で売られているパッケージPCです。 [url=http://www.key7jp.com/access-2016-54.html]office2016 メディア 購入[/url]
    まずは、起動やソフトの立ち上がり、シャットダウンの速さに驚いた。 ・2010/8月 各自治体 OpenOffice 導入進む 記事・2011/5月 株式会社 アシストLibreOffice ヘルプデスク サービスなど LibreOffice 支援サービスを提供開始。
    [url=http://www.key7jp.com/windows7-06-15.html]win7 アップグレード[/url] Windows8 Pro を゗ン ストールした後、ユーザゕプリケーション設定、Windows の設定、 およびユーザーのフゔ゗ルが維持されていることを確認する必要があります。 千葉のハムの集いで購入してきた「ワンセグチューナー」でSDR受信機をパソコン(Windows7)にインストールしてやってみました。
    [url=http://www.key7jp.com/office-Professional-2016-plus-5pc-62.html]office2016 ソフト[/url]

  14. 2017年11月12日03:36 | #14

    Hi, I do think this is a great site. I stumbledupon it ;) I am going to
    come back yet again since i have bookmarked it.
    Money and freedom is the greatest way to change, may you be
    rich and continue to help others.

  15. 2017年11月13日04:01 | #15

    Harley appoints main printing on police.

  16. 2017年11月15日08:11 | #16

    Hey I know this is off topic but I was wondering if you knew of any widgets I
    could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time
    and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your blog
    and I look forward to your new updates.

  17. 2017年11月15日17:21 | #17

    Pretty nice post. I just stumbled upon your weblog and wanted to mention that I’ve
    truly loved surfing around your weblog posts.

    In any case I’ll be subscribing in your rss
    feed and I am hoping you write again soon!

  18. 2017年11月16日06:14 | #18

    You can definitely see your expertise in the article you write.
    The world hopes for more passionate writers such as you who aren’t
    afraid to mention how they believe. At all times follow your heart.

  19. 2017年11月16日20:26 | #19

    Are you feeling to may well be more assure at your house?

  20. 2017年11月22日18:22 | #20

    bad credit lenders
    direct payday lender
    bad credit personal loans not payday loans
    payday loans baton rouge
    las vegas payday loans

  21. 2017年11月25日12:14 | #21

    This message is posted here using XRumer + XEvil 4.0
    XEvil 4.0 is a revolutionary application that can bypass almost any anti-botnet protection.
    Captcha Recognition Google (ReCaptcha-1, ReCaptcha-2), Facebook, Yandex, VKontakte, Captcha Com and over 8.4 million other types!
    You read this – it means it works! ;)
    Details on the official website of XEvil.Net, there is a free demo version.

  22. 2017年12月1日16:17 | #22

    cash loans
    cash loans
    cash advance
    payday loans online
    online payday loans

  23. 2017年12月4日07:45 | #23

    [url=http://cialisonlineytfrx.com/]buy cialis online[/url]
    best place to buy cialis cialis
    http://cialisonlineytfrx.com
    tadalafil api cialis generic
    generic cialis

  24. 2017年12月4日07:46 | #24

    [url=http://cialisonlineytfrx.com/]cialis cheap[/url]
    viagra beograd cialis pills
    http://cialisonlineytfrx.com
    vicodin identify buy cialis online buy
    cialis online

  25. 2017年12月4日08:55 | #25

    [url=http://viagranorxonlineviagra.accountant/]buy generic viagra[/url]
    viagra 3 day delivery
    http://viagranorxonlineviagra.accountant
    viagra on line
    buy generic viagra

  26. 2017年12月4日12:27 | #26

    [url=http://cialisonlineytfrx.com/]generic cialis online[/url]
    viagra rapid tabs cialis pills
    http://cialisonlineytfrx.com
    is generic cialis good
    buy cialis online

  27. 2017年12月4日13:42 | #27

    [url=http://viagranorxonlineviagra.accountant/]buy viagra online[/url]
    100 mg viagra effects
    http://viagranorxonlineviagra.accountant
    whats in viagra
    generic viagra

  28. 2017年12月4日17:08 | #28

    [url=http://cialisonlineytfrx.com/]generic cialis online[/url]
    buy cialis cheap
    http://cialisonlineytfrx.com
    cheap cialis without prescription
    generic cialis

  29. 2017年12月5日02:05 | #29

    [url=http://cialisonlineytfrx.com/]cialis online[/url]
    cialis generic tadalafil
    http://cialisonlineytfrx.com
    ciali
    generic cialis

  30. 2017年12月6日01:33 | #30

    payday loans online
    online payday loans
    payday loan online
    pay day loan
    online payday loans

  31. 2017年12月9日01:33 | #31

    slot machines
    casino online
    slot games
    casino games
    free casino games

  32. 2017年12月16日02:28 | #32

    Hi, i read your blog from time to time and i own a similar one and i was just curious if you get a lot of spam feedback?

    If so how do you protect against it, any plugin or anything you
    can advise? I get so much lately it’s driving me mad so any
    support is very much appreciated.

  33. 2017年12月20日09:38 | #33

    casino online usa
    casino games
    online casino games
    online casino games
    casino games

  34. 2017年12月23日01:33 | #34

    payday loans no credit check
    payday loans no credit check
    payday loans no credit check
    payday loans no credit
    payday loans online no credit check

  35. 2017年12月24日16:07 | #35

    Hello! Would you mind if I share your blog with my facebook
    group? There’s a lot of folks that I think would really enjoy your content.
    Please let me know. Many thanks

  36. 2017年12月28日07:11 | #36

    online casino
    online casino
    casino online
    casino online
    real money casino

  37. 2017年12月29日04:18 | #37

    hello there and thank you for your info – I have certainly picked
    up something new from right here. I did however expertise several technical points using
    this website, as I experienced to reload the website
    lots of times previous to I could get it to load properly.
    I had been wondering if your hosting is OK? Not that I’m complaining, but
    sluggish loading instances times will very frequently affect your placement in google and could damage your high quality score if advertising and marketing
    with Adwords. Anyway I’m adding this RSS to my email and could look out for a lot more
    of your respective exciting content. Ensure that you update this again soon.

  38. 2018年1月2日00:05 | #38

    casino en ligne rtg
    casino real money
    casino online with american express

  39. 2018年1月3日02:52 | #39

    payday loans online no credit check
    loans online
    payday loans online no credit check
    loans for bad credit
    payday loans no credit check

  40. 2018年1月8日11:37 | #40

    free slots casino games
    free casino slots
    free slot games
    aol slots
    slots casino

  41. 2018年1月10日21:47 | #41

    Thank you for some other informative site. Where else could I am
    getting that kind of information written in such an ideal approach?
    I’ve a undertaking that I am simply now running on, and I’ve been on the glance out for such information.

  42. 2018年1月12日12:15 | #42

    upgrade autocad lt
    autocad 2018
    key autocad 2017

  43. 2018年1月14日16:11 | #43

    loans no credit
    payday loans no credit check
    payday loans no credit
    loans no credit check
    loans for bad credit

  44. 2018年1月15日02:26 | #44

    Howdy! This post couldn’t be written much better!
    Looking at this post reminds me of my previous roommate!
    He continually kept preaching about this.
    I am going to send this post to him. Pretty sure he will have a great read.
    Thanks for sharing!

  45. 2018年1月15日10:51 | #45

    I am regular reader, how are you everybody?
    This post posted at this web site is actually pleasant.

评论分页
1 2 3 4 125
订阅评论
5+4= (必填)