2014-09-03 73 views
1

我已經安裝了一個Magento擴展程序,讓它有一個與Magento集成的wordpress博客。 基本上,WP位於Magento根目錄的子目錄中。我想創建多個包含子目錄的站點,但由於nginx配置,我無法使其工作。magento根子文件夾中wordpress博客的Nginx配置

WordPress是在他/ WP子目錄(http://example.com/wp/wp-admin/),其他網站都可以訪問來自http://example.com/wp/ca/wp-admin/http://example.com/wp/en/wp-admin/

這裏是什麼我走到這一步:

server 
{ 
    server_name dev.example.com; 
    access_log /var/log/nginx/example.access.log;- 
    error_log /var/log/nginx/example.error.log; 
    root /var/www/example; 

    location ^~ /wp { 
     index index.php index.html index.htm; 
     try_files $uri $uri/ /wp/index.php?q=$uri&$args; 

     # Multisite 
     if (!-e $request_filename) { 
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;   
      rewrite ^/wp(/[^/]+)?(/wp-.*) /wp$2 last;  
      rewrite ^/wp(/[^/]+)?(/.*\.php)$ /wp$2 last; 
     } 

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

    set    $mage_developer true; 
    set    $mage_code es; 
    set    $mage_type store; 
    include   snippets.d/magento-site;- 
} 

和snippets.d/Magento的-site:

# Serve static pages directly, 
# otherwise pass the URI to Magento's front handler 
location/{ 
    index  index.php; 
    try_files $uri $uri/ @handler; 
    expires  30d;- 
} 

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

# Allow admins only to view export folder 
location /var/export/ { 
    auth_basic    "Restricted"; 
    auth_basic_user_file  htpasswd; 
    autoindex    on; 
} 

# 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; } 

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

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

# Execute PHP scripts 
location ~ .php$ { 

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

    expires  off; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include  fastcgi_params; 
    fastcgi_param MAGE_RUN_CODE $mage_code; 
    fastcgi_param MAGE_RUN_TYPE $mage_type; 
    fastcgi_ignore_client_abort on; 
    fastcgi_read_timeout 900s; # 15 minutes 
} 

感謝您的幫助。

回答

1

那麼,最後,它的工作原理是將所有的請求傳遞給Apache,並在相應的虛擬主機中創建站點。

location ~ ^/blog { 
proxy_pass   http://apache:80; 
proxy_set_header X-Real-IP $remote_addr; 
proxy_set_header Host $host; 
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
proxy_read_timeout 6000s; 
} 

如果有人成功,使其只Nginx的工作,我很期待他的回答:)

+0

讓我很快樂,謝謝! – 2015-01-27 16:01:03

0

爲什麼運行Apache?運行2個Web服務器沒有意義。 嘗試將此添加到您的nginx conf。

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

location ^~ /wp { 
root /var/www/example; 
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; 
} 
} 
1

想要傳遞一個完整的conf文件給任何需要配置它的人。請記住,許多文件路徑在您的服務器配置中是唯一的。

請注意,你需要調整基於文件路徑的服務器上以下參數:

server_name domain.com www.domain.com; 
ssl_certificate  /sslpath/domain.com.crt; 
ssl_certificate_key /sslpath/domain.com.key; 
root  /webrootpath/domain.com; 
rewrite ^/blogpath(.*) /blogpath/index.php?q=$1; 
location ^~ /blogpath { 
error_log /data/log/nginx/domain.com_error.log; 
access_log /data/log/nginx/domain.com_access.log; 

這裏是整個nginx的的c​​onf文件:

server { 
    listen  80; 
    server_name domain.com www.domain.com; 
    rewrite ^ https://$server_name$request_uri? permanent; 
} 

server { 
    listen 443; 
    server_name domain.com www.domain.com; 

    ssl on; 
    ssl_certificate  /sslpath/domain.com.crt; 
    ssl_certificate_key /sslpath/domain.com.key; 
    ssl_session_timeout 30m; 

root  /webrootpath/domain.com; 
index  index.php; 
location/{ 
    index index.html index.php; 
    try_files $uri $uri/ @handler; 
    expires 30d; 
} 

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

location ^~ /blogpath { 
    root /webrootpath/domain.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; 
} 
} 

location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; } 
location /var/export/ { internal; } 
location /. { return 404; } 
location @handler { rewrite//index.php; } 
location ~* .php/ { rewrite ^(.*.php)/ $1 last; } 
location ~* .php$ { 
    if (!-e $request_filename) { rewrite//index.php last; } 
    expires off; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_param MAGE_RUN_CODE default; 
    fastcgi_param MAGE_RUN_TYPE store; 
    include fastcgi_params; 
} 

error_log /data/log/nginx/domain.com_error.log; 
access_log /data/log/nginx/domain.com_access.log; 

}