Nginx:提供不同根目录下的magento站点以及其他magento根目录下的子目录

经过数小时的search和testing,我还没有得到这个工作。 我在/ srv / site1 / htdocs有一个正在运行的magento安装。 我在/ srv / site2 / htdocs有另一个magento安装。 我需要site2加载在site1.com/site2/。 棘手的权利?

到目前为止,我已经有site1.com/site2加载了一个无风格的404页面,用于site2 magento安装,这个目录里面的所有内容都会抛出一个404.下面是我的整个nginx conf:

server { listen 80; server_name site1.com; root /srv/site1.com/htdocs; index index.php; client_max_body_size 500M; location ~ /site2 { root /srv/site2/htdocs; add_header Access-Control-Allow-Origin "*"; index index.php index.html; try_files $uri $uri/ /index.php?$args; expires 30d; location ~* \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php-fpm/www.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_read_timeout 20000000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include mime.types; } location ~ /site2/.+\.php$ { root /srv/site2/htdocs; try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php-fpm/www.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_read_timeout 20000000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include mime.types; } } location / { add_header Access-Control-Allow-Origin "*"; index index.php; ## Allow a static html file to be shown first try_files $uri $uri/ /index.php?$args; expires 30d; } 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 text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss; ## 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 ~ /\.htaccess { ## Disable .htaccess and other hidden files return 404; } location ~ \.php$ { if ($request_uri ~ /site2/.*$) { root /srv/site2/htdocs; } try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php-fpm/www.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_read_timeout 20000000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include mime.types; } location ~* \.(?:manifest|appcache|html?|xml|json)$ { expires -1; } # Feed location ~* \.(?:rss|atom)$ { expires 1h; add_header Cache-Control "public"; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1M; access_log off; add_header Cache-Control "public"; } # CSS and Javascript location ~* \.(?:css|js)$ { expires 1y; access_log off; add_header Cache-Control "public"; } } 

在那里的一些冗余代码位肯定。 几乎在我的白衣在这里结束。 有任何想法吗? 我还需要为另一个magento站点site1.com/site3做到这一点。 有趣的东西确实。