Назад | Перейти на главную страницу

Используете wordpress в качестве подкаталога установки drupal?

Я запускаю Ubuntu 10.04 с NginX 0.7.65.

У меня установлен Drupal в корневом каталоге, и он отлично работает с соответствующим образом настроенным файлом vhost, но теперь я хотел бы установить Wordpress в подкаталог в том же домене. Когда я перехожу на example.com/wordpress, возникает ошибка 404, которую обрабатывает Drupal. Вот мой файл vhost:

    server {
        server_name www.example.com example.com;
        access_log /srv/www/example.com/logs/access.log;
        error_log /srv/www/example.com/logs/error.log;
        root /srv/www/example.com/public_html;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        # This matters if you use drush
        location = /backup {
                deny all;
        }

        # Very rarely should these ever be accessed outside of your lan
        location ~* \.(txt|log)$ {
                allow 192.168.0.0/16;
                deny all;
        }

        location ~ \..*/.*\.php$ {
                return 403;
        }

        location / {
                # This is cool because no php is touched for static content
                try_files $uri @rewrite;
        }

        location @rewrite {
                # Some modules enforce no slash (/) at the end of the URL
                # Else this rewrite block wouldn't be needed (GlobalRedirect)
                rewrite ^/(.*)$ /index.php?q=$1;
        }

        location ~ \.php$ {
                include conf-inc.d/fastcgi.conf;
                track_uploads uploads 60s;
        }

        # The Nginx module wants ?X-Progress-ID query parameter so
        # that it report the progress of the upload through a GET
        # request. But the drupal form element makes use of clean
        # URLs in the POST.
        location ~ (.*)/x-progress-id:(\w*) {
                rewrite ^(.*)/x-progress-id:(\w*)  $1?X-Progress-ID=$2;
        }

        # Now the above rewrite must be matched by a location that
        # activates it and references the above defined upload
        # tracking zone.
        location ^~ /progress {
                report_uploads uploads;
        }

        # Fighting with ImageCache? This little gem is amazing.
        location ~ ^/sites/.*/files/imagecache/ {
                try_files $uri @rewrite;
        }

        # Catch image styles for D7 too.
        location ~ ^/sites/.*/files/styles/ {
                try_files $uri @rewrite;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

        # Deny access to Apache .htaccess files.
        location ~ /\.ht {
                deny all;
        }

}

Вдохновляйтесь ответами на аналогичная тема на SO

Проблема в этой директиве местоположения для php-fallback

location / {
        # This is cool because no php is touched for static content
        try_files $uri @rewrite;
}

location @rewrite {
        # Some modules enforce no slash (/) at the end of the URL
        # Else this rewrite block wouldn't be needed (GlobalRedirect)
        rewrite ^/(.*)$ /index.php?q=$1;
}

С этой конфигурацией вы переписываете все запросы в drupal index.php, включая ваши файлы wordpress. Решением является определение одного блока местоположения для обработки резервной копии php для wordpress.

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

В этом месте вы переписываете весь запрос в wordpress index.php.