2012-01-25 21 views
16

के साथ डिफ़ॉल्ट रूप से नहीं खोल सकता है मेरी सर्वर परिभाषा के साथ क्या गलत है? अगर मैं "www.testing.com" तक पहुंचने का प्रयास करता हूं तो मुझे index.php के बजाय डाउनलोड करने के लिए बाइनरी मिलती है, इसके बजाय अगर मैं "test.com" तक पहुंचने का प्रयास करता हूं तो मुझे index.php मिलता है।डिफ़ॉल्ट रूप से index.php को nginx

servername testing.com; 
servername testing.com www.testing.com; 
servername testing.com www.testing.com *.testing.com; 

वही व्यवहार:

मैं पहले से ही करने के लिए सर्वर स्थापित करने के लिए करने की कोशिश की मैं index.php "www.testing.com" के साथ नहीं मिल सकता है, बस के साथ "testing.com"। (ऑफ कोर्स test.com मेरा नहीं है उदाहरण के लिए)।

user    nginx; 
    worker_processes 4; 
    error_log   /var/log/nginx/error.log warn; 
    pid    /var/run/nginx.pid; 

    events { 
     worker_connections 1024; 
    } 


    http { 
     include  /etc/nginx/mime.types; 
     default_type text/plain; 

     log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
          '$status $body_bytes_sent "$http_referer" ' 
          '"$http_user_agent" "$http_x_forwarded_for"'; 

     access_log /var/log/nginx/access.log main; 

     fastcgi_intercept_errors on; 
     sendfile     on; 
     keepalive_timeout   65; 
     gzip      on; 
     index      index.php index.html index.htm; 

     server { 
       listen 80; 
       server_name www.testing.com; 
       root /home/vhosts/testing; 

       location/{ 
        try_files $uri $uri/ /index.php index.php; 
       } 

     location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { 
        expires max; 
        add_header Pragma public; 
        add_header Cache-Control "public, must-revalidate, proxy-revalidate"; 
       } 

     location ~* \.php$ { 
       try_files $uri =404; 
       include fastcgi.conf; 
       fastcgi_pass 127.0.0.1:9000; 
       } 
     } 
    } 

उत्तर

-1

आप एक से अधिक servername लाइन हो सकते हैं, यह उन सभी पर एक VHOST स्थापित करेगा।

+0

आप वह मतलब है की जरूरत है नहीं कर सकते? – Purefan

8

location ~* \.php$

location ~* \.php$ { 
       try_files $uri =404; 
       include fastcgi.conf; 
       fastcgi_pass 127.0.0.1:9000; 
       fastcgi_index index.php; 
       } 
+1

+1 यह मेरे लिए काम किया, धन्यवाद! – coma

0

में fastcgi_index index.php; जोड़ने की जाँच अपने एफ पी एम runing है और उसके पर 127.0.0.1:9000

location ~ \.php$ { 
    try_files $uri =404; 
    include fastcgi.conf; 
    fastcgi_pass 127.0.0.1:9000; 
} 

भी त्रुटि लॉग इन करें और नमूना conf जाँच के लिए जाँच

error_log /var/log/nginx/error.log debug; 

https://github.com/rtCamp/easyengine/blob/master/conf/nginx/singlesite/basic.conf

18

पहले आप अपने php-एफ पी एम सेटिंग्स की जाँच करने के लिए (शायद आप अपने php-एफ पी एम विन्यास में पोर्ट के बजाय सॉकेट कनेक्शन का उपयोग कर) और अपना स्थान में डिफ़ॉल्ट रूप से सूचकांक जोड़ने "/"

location/{ 
    index index.php index.html index.htm; 
    try_files $uri $uri/ =404; 
} 
संबंधित मुद्दे