2011-05-27 10 views
21

मैंने कई अलग-अलग चीजों की कोशिश की है।Nginx - एक उपनिर्देशिका में WordPress, क्या डेटा पारित किया जाना चाहिए?

location ^~ /wordpress { 
    alias /var/www/example.com/wordpress; 
    index index.php index.html index.htm; 
    try_files $uri $uri/ /wordpress/index.php; 

    location ~ \.php$ { 
     include fastcgi_params; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_split_path_info ^(/wordpress)(/.*)$; 
     fastcgi_param SCRIPT_FILENAME /var/www/example.com/wordpress/index.php; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
    } 
} 

अभी, सभी संसाधनों जहाँ तक मैं बता सकता है (छवि, आदि) सही ढंग से लोड कर रहे हैं: बिंदु मैं अभी पर हूँ यह है। और http://www.example.com/wordpress वर्डप्रेस लोड करता है, लेकिन एक पृष्ठ जो "पृष्ठ नहीं मिला" कहता है। (हालांकि इसके लिए वर्डप्रेस उपयोग में है)। अगर मैं किसी भी पोस्ट यूआरएल का प्रयास करता हूं तो मुझे एक ही परिणाम मिलता है, "पृष्ठ नहीं मिला"। तो मुझे पता है कि समस्या यह है कि वर्डप्रेस पथ या कुछ के बारे में डेटा प्राप्त नहीं कर रहा है। एक अन्य संभावित समस्या यह है कि यदि मैं example.com/wp-admin.php चलाता हूं तो यह अभी भी index.php चलाएगा।

किस डेटा को पारित करने की आवश्यकता है? क्या गलत हो रहा है?

उत्तर

39

चूंकि आपका स्थान ऊर्फ अंत मैच है, तो आपको बस रूट का उपयोग करना चाहिए। इसके अलावा, सब कुछ वर्डप्रेस afaik पर index.php के माध्यम से भेजा जाता है। साथ ही, जब तक आपको पता न हो कि आपको पथ की जानकारी चाहिए, तो शायद आप नहीं। मुझे लगता है कि आप की तरह कुछ हैं:

location @wp { 
    rewrite ^/wordpress(.*) /wordpress/index.php?q=$1; 
} 

location ^~ /wordpress { 
    root /var/www/example.com; 
    index index.php index.html index.htm; 
    try_files $uri $uri/ @wp; 

    location ~ \.php$ { 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
     fastcgi_pass 127.0.0.1:9000; 
    } 
} 

या तुम सच में पथ की जानकारी (यूआरएल /wordpress/index.php/foo/bar की तरह लग रहे) की जरूरत है, तो:

location ^~ /wordpress { 
    root /var/www/example.com; 
    index index.php index.html index.htm; 
    try_files $uri $uri/ /wordpress/index.php; 

    location ~ \.php { 
     fastcgi_split_path_info ^(.*\.php)(.*)$; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 
     fastcgi_pass 127.0.0.1:9000; 
    } 
} 

संपादित करें: अपडेट किए गए प्रथम सर्वर {} uri से प्रारंभिक/वर्डप्रेस पट्टी और q परम के रूप में शेष पारित

EDIT2 रहे हैं: नाम स्थानों सर्वर स्तर

+0

मैं कोशिश करता हूं कि (आपका पहला वाला) लेकिन मुझे 404 शब्द नहीं मिला है। मुझे ब्लॉग को एक अलग डोमेन से एक उपनिर्देशिका के साथ डोमेन में ले जाने के साथ करना पड़ सकता है। – Matthew

+0

मुझे लगता है कि शायद WordPress को प्रारंभिक/वर्डप्रेस छीनने की आवश्यकता है। ऐसा करने के लिए पहले सर्वर को संपादित किया। – kolbyjack

+4

यह निश्चित उत्तर है !!! मैंने 'रूट' के स्थान पर 'स्थान^~/वर्डप्रेस' और 'उपनाम' के स्थान पर 'स्थान/वर्डप्रेस' के साथ पहला समाधान उपयोग किया है। – micred

12

Dude, इस का एक उपनिर्देशिका में एक वर्डप्रेस ब्लॉग के लिए के लिए काम करेंगे पर ही मान्य हैं Magento रूट फ़ोल्डर!

server { 
listen 80; 
server_name my-site.co.uk; 
rewrite/$scheme://www.$host$request_uri permanent; ## Forcibly prepend a www 
} 

server { 
listen 80 default; 
client_max_body_size 8M; 
## SSL directives might go here 
server_name www.my-site.co.uk; ## Domain is here twice so server_name_in_redirect will favour the www 
root /var/www/my-site/magento; 

location/{ 
    index index.html index.php; ## Allow a static html file to be shown first 
    try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler 
    expires 30d; ## Assume all files are cachable 
} 

location /wordpress { 
      index index.php index.html index.htm; 
     try_files $uri $uri/ /wordpress/index.php; 
     } 

## These locations would be hidden by .htaccess normally 
location ^~ /app/    { deny all; } 
location ^~ /includes/   { deny all; } 
location ^~ /lib/    { deny all; } 
location ^~ /media/downloadable/ { deny all; } 
location ^~ /pkginfo/   { deny all; } 
location ^~ /report/config.xml { deny all; } 
location ^~ /var/    { deny all; } 

location /var/export/ { ## Allow admins only to view export folder 
    auth_basic   "Restricted"; ## Message shown in login window 
    auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword 
    autoindex   on; 
} 

location /. { ## Disable .htaccess and other hidden files 
    return 404; 
} 


location @handler { ## Magento uses a common front handler 
    rewrite//index.php; 
} 

location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler 
    rewrite ^(.*.php)/ $1 last; 
} 

location ~ .php$ { ## Execute PHP scripts 
    if (!-e $request_filename) { rewrite//index.php last; } ## Catch 404s that try_files miss 

    expires  off; ## Do not cache dynamic content 
    fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_param HTTPS $fastcgi_https; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores 
    fastcgi_param MAGE_RUN_TYPE store; 
    include  fastcgi_params; ## See /etc/nginx/fastcgi_params 
} 

}

+0

यदि कोई कोर कॉन्फ़िगरेशन फ़ाइल चाहता है तो मैं इस साइट कॉन्फ़िगरेशन के साथ Nginx के लिए उपयोग कर रहा हूं, बस मुझे बताएं। –

+0

मेरे लिए काम करता है, मैगेंटो का उपयोग नहीं कर रहा हूं लेकिन वर्डप्रेस के लिए वह ब्लॉक उपयोगी है। thx – risnandar

+0

मुझ से अंगूठे! बहुत सरल और सीधा, वह वर्डप्रेस हिस्सा और मेरी साइट के लिए पूरी तरह से काम किया। मुझे codex.wordress.com पर बहुत जटिल होने का उदाहरण मिला! –

1

मैं एक ही समस्या थी और यह है कि क्या यह मेरे लिए तय है: आपकी साइट के लिए

  1. ओपन nginx विन्यास फाइल। सर्वर ब्लॉक के अंदर, अपने रूट निर्देशिका में पथ जोड़ सकते हैं और फ़ाइलों के लिए प्राथमिकता क्रम सेट:

    root /mnt/www/www.domainname.com; 
    index index.php index.html index.htm; 
    
  2. एक खाली स्थान ब्लॉक बनाएं अपने सभी अन्य स्थान ब्लॉक से पहले:

    location /latest { 
    # Nothing in here; this is to avoid redirecting for this location 
    } 
    
  3. अपने स्थान/ब्लॉक में रूट निर्देशिका की सराहना करें और पुनर्निर्देशन जोड़ें ताकि यह इस तरह दिखता है:

    location/{ 
    # root /mnt/www/www.domainname.com; 
    index index.php index.html index.htm; 
    rewrite ^/(.*)$ http://www.domainname.com/latest/$1 redirect; 
    } 
    
  4. को

    root /mnt/www/www.domainname.com; 
    

यह मेरे लिए यह तय कर लें कि आपके स्थान ~ .php $ ब्लॉक की जड़ बताते हैं बनाओ।

संबंधित मुद्दे