2

After many hours of googling and testing I have yet to get this to work. I have a functioning magento install at /srv/site1/htdocs . I have another magento install at /srv/site2/htdocs . I need site2 to load at site1.com/site2/ . Tricky right?

So far I've got site1.com/site2 loading an unstyled 404 page for the site2 magento install, and everything else inside of this directory throws a 404. Here's my entire 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";
    }
}

Bit of some redundant code in there for sure. Almost at my whit's end here. Any ideas? I'll also need to do this for yet another magento site, site1.com/site3 . Fun stuff indeed.

David
  • 187
  • 2
  • 15

0 Answers0