Nginx

2013-04-26 11 views
5

प्रदर्शित करने के बजाय फ़ाइल डाउनलोड करने का प्रयास करता है मैं Nginx स्थापित करता हूं और सबडोमेन और डोमेन करता हूं। सबडोमेन में php5-fpm और wordpress है। यह ठीक काम करता है और साइट्स-सक्षम के लिए सिमलिंक की गई एक साइट-उपलब्ध फ़ाइल में है। डोमेन में PHP नहीं है और इसमें फ़ाइल भी सिम्लिंक है। जब मैं डोमेन पर जाता हूं तो सर्वर को पुनरारंभ करने के बाद भी यह HTML फ़ाइल डाउनलोड करने का प्रयास करता है।Nginx

 server { 
     server_name www.example.us; 
     rewrite ^(.*) http://example.us$1 permanent; 
    } 

    server { 
      listen 80; 
      server_name example.us; 
        root /var/www/example; 
      index index.php; 
      autoindex on; 
      autoindex_exact_size off; 
      include /etc/nginx/security; 
    # Logging -- 
    access_log /var/log/nginx/example.us.access.log; 
    error_log /var/log/nginx/example.us.error.log notice; 
      # serve static files directly 
      location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { 
       access_log off; 
       expires max; 
      } 

#   location ~ \.php$ { 
#   try_files $uri =404; 
#     fastcgi_pass unix:/var/run/php5-fpm/example.us.socket; 
#     fastcgi_index index.php; 
#     include /etc/nginx/fastcgi_params; 
#   } 
    } 

nginx.conf फ़ाइल है::

user www-data; 
worker_processes 4; 
pid /var/run/nginx.pid; 

events { 
    worker_connections 768; 
    # multi_accept on; 
} 
http { 
# Basic Settings 
    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 
    # server_tokens off; 

    # server_names_hash_bucket_size 64; 
    # server_name_in_redirect off; 

    include /etc/nginx/mime.types; 
    default_type application/octet-stream; 
# Logging Settings 
log_format gzip '$remote_addr - $remote_user [$time_local] ' 
       '"$request" $status $bytes_sent ' 
       '"$http_referer" "$http_user_agent" "$gzip_ratio"'; 
    access_log /var/log/nginx/access.log gzip buffer=32k; 
    error_log /var/log/nginx/error.log notice; 
# Gzip Settings 
    gzip on; 
    gzip_disable "msie6"; 
    gzip_vary on; 
    gzip_proxied any; 
    gzip_comp_level 6; 
    gzip_buffers 16 8k; 
    gzip_http_version 1.1; 
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
# Virtual Host Configs 
    include /etc/nginx/conf.d/*.conf; 
    include /etc/nginx/sites-enabled/*; 
} 
+0

ठीक है, अब मैं और भी उलझन में हूं। मैं एडब्ल्यूएस पर एक उदाहरण चला रहा हूँ। मैंने इंस्टेंस बंद कर दिया और मैं अभी भी फाइल डाउनलोड कर सकता हूं। तो, यह नहीं होना चाहिए। – moosilauke18

उत्तर

5

default_type application/octet-stream; निकालें यहाँ मेरी साइटों से उपलब्ध डोमेन के लिए पृष्ठ है। यह लाइनें ब्राउज़र को लगता है कि यह कुछ बाइनरी डेटा है और HTML नहीं।

+0

डिफ़ॉल्ट_ टाइप, किसी अन्य सुझाव पर टिप्पणी करने के बाद भी मुझे एक ही समस्या है? मेरे उदाहरण में –

+0

समस्या यह थी कि PHP स्थापित नहीं किया गया था। इसे स्थापित करने के बाद मुझे सही होस्ट/पोर्ट पर सुनने के लिए php-fpm मिलना पड़ा। /etc/php5/fpm/pool.d/www.conf में निम्न पंक्ति को बदलें: listen = /var/run/php5-fpm.sock करने के लिए: सुनो = 127.0.0.1:9000 PHP-fpm को पुनरारंभ करें sudo /etc/init.d/php5-fpm पुनरारंभ करें और सब कुछ काम करना चाहिए। गुडलक और अतिरिक्त सहायता के लिए इस लिंक पर एक नज़र डालें http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm –

+3

@ArminNehzat Nginx फ़ाइल परोसता है और php-fpm नहीं, यही कारण है कि यह है डाउनलोड हो रहा है। पता लगाएं कि फ़ाइल सीधे Nginx के साथ क्यों भेजी जाती है और php-fpm के माध्यम से नहीं। – Gustav