WordPress.org

Ready to get started?Download WordPress

Forums

Need help in setting up file nginx.conf for WP MU 2.7.1 (8 posts)

  1. freedom373
    Member
    Posted 1 year ago #

    [ Moderator note: edited for readability, no data was changed. ]

    Hello!

    I have already written same topic in russian forum but has not yet received a response.
    Please help!
    It task very important for me!

    --
    We have: WordPress Multi User 2.7.1

    about it:

    - wasn't created from the bigining(from zero), but was bought for next working with it.

    - setting up the working mode for subdomains (visiters come in blog follow by link same as: blog1.mainsite.com)

    - there are many blogs working now on it.
    ---

    EXIST MAIN TASK:

    change the working mode of WP MU from "subdomains" to "subdirectory"
    that if visiter try to go to "blog1.mainsite.com", it will be redirect to "mainsite.com/blog1/" or "www.mainsite.com/blog1/"

    ====
    parameters of the site that must be configured:
    1) domain name = http://wyinc.ru/
    2) web-server = nginx-0.6.32-3+lenny3
    3) PHP Version 5.2.6-1+lenny10
    4) WordPress MU 2.7.1
    5) it is likely that is setting up a bunch of nginx (as a front-end) and apache(as a back-end)
    (As here http://habrahabr.ru/post/120814/)

    ====

    What has been done to solve this problem yourself.

    1.1 to read the articles:
    1.1.1 http://codex.wordpress.org/%D0%A1%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5_%D1%81%D0%B5%D1%82%D0%B8
    1.1.2 http://codex.wordpress.org/Nginx
    1.1.3 http://wordpress.org/support/topic/nginx-php-fpm-php-apc-wordpress-multisite-subdirectory-wp-super-cache
    1.1.4 many of articles related to the required tasks on this forum.
    1.1.5 http://journalxtra.com/websiteadvice/wordpress/how-to-force-multi-site-to-use-subdirectories-2427/

    and other

    ==============

    2. The decision was found ---

    2.1 ---- Create file .htaccess or modify it --- if server was = Apache and write appropriate code. At first made changes(described below) in .htaccess --- which cause errors = 500 Internal Error (just at the beginning thought that Apache is on this hosting the usual default)

    contents of .htaccess before making changes:

    -----
    AddDefaultCharset UTF-8
    RewriteEngine On
    RewriteBase / 
    
    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L] 
    
    # add a trailing slash to /wp-admin
    RewriteCond %{REQUEST_URI} ^.*/wp-admin$
    RewriteRule ^(.+)$ $1/ [R=301,L] 
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . – [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L] 
    
    <IfModule mod_security.c>
    <Files async-upload.php>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </Files>
    </IfModule>
    -----

    contents of .htaccess after making changes (only without line numbers, we have made), (I have the line numbers to draw your attention to the line number 4 and 11 - they (the source code that was given to link to 1.1.1 (listed above - see "Switching between subdomains and subdirectories" in the end of the article described by reference), I amended by removing the hyphen "-" in front of the flag of [L] in both lines) --- correct me if it did not have to do:

    -----
    1 # BEGIN WordPress 
    
    2 RewriteEngine On
    3 RewriteBase /
    4 RewriteRule ^index\.php$ [L] 
    
    5 # uploaded files
    6 RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] 
    
    7 # add a trailing slash to /wp-admin
    8 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] 
    
    9 RewriteCond %{REQUEST_FILENAME} -f [OR]
    10 RewriteCond %{REQUEST_FILENAME} -d
    11 RewriteRule ^ [L]
    12 RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
    13 RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    14 RewriteRule . index.php [L] 
    
    15 # END WordPress
    -----

    --- which cause errors = 500 Internal Error (just at the beginning thought that Apache is on this hosting the usual default)

    ==========================

    2.2 And also try to change a file nginx.conf --- together with the changes in the .htaccess (see previous item)

    insert code were different, as has been analyzed many sources. also its code insertion created by convert [to clear directive (nginx)] pasting from. htaccess (above). Only had available the 4th version of the code.

    bring them down.

    After each option --- overloaded server nginx - via an ISP, but could not - so ask a support hosting provider - he did it..

    2.2.1 First version of the code
    ==========

    }
    server {
    listen 46.4.67.247:80;
    server_name wyinc.ru www.wyinc.ru;
    rewrite ^(/manager/.*)$ https://$host$1 permanent;
    rewrite ^(/manager/.*)$ https://$host$1 permanent; 
    
    #on server block
    ##necessary if using a multi-site plugin
    server_name_in_redirect off;
    ##necessary if running Nginx behind a reverse-proxy
    port_in_redirect off; 
    
    rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
    if (!-e $request_filename) {
    rewrite ^.+?(/wp-.*) $1 last;
    rewrite ^.+?(/.*.php)$ $1 last;
    rewrite ^ /index.php last;
    } 
    
    location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location / {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^.+.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|av i|zip|gz|bz2?|rar)$ {
    root /var/www/bra1n/data/www/wyinc.ru;
    access_log /var/www/httpd-logs/wyinc.ru.access.log;
    error_page 404 = @fallback;
    }
    location @fallback {
    proxy_pass 46.4.67.247:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    }
    =========

    2.2.2 Second version of the code

    =============
    }
    server {
    listen 46.4.67.247:80;
    server_name wyinc.ru www.wyinc.ru;
    rewrite ^(/manager/.*)$ https://$host$1 permanent;
    rewrite ^(/manager/.*)$ https://$host$1 permanent; 
    
    if (!-e $request_filename) {
    rewrite ^.+?(/wp-.*) $1 last;
    rewrite ^.+?(/.*.php)$ $1 last;
    rewrite ^ /index.php last;
    } 
    
    location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    } 
    
    location ~ .php$
    {
    root /../;
    index.php;
    ..
    } 
    
    location / {
    root /../;
    index.php;
    rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^.+.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|av i|zip|gz|bz2?|rar)$ {
    root /var/www/bra1n/data/www/wyinc.ru;
    access_log /var/www/httpd-logs/wyinc.ru.access.log;
    error_page 404 = @fallback;
    }
    location @fallback {
    proxy_pass 46.4.67.247:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    }
    =============

    2.2.3 Third version of the code

    =============
    }
    server {
    listen 46.4.67.247:80;
    server_name wyinc.ru www.wyinc.ru;
    rewrite ^(/manager/.*)$ https://$host$1 permanent;
    rewrite ^(/manager/.*)$ https://$host$1 permanent; 
    
    rewrite ^/index.php$ last;
    rewrite ^/([_0-9a-zA-Z-]+/)?files/(.+) /wp-includes/ms-files.php?file=$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent; #301 redirect
    rewrite ^/ last;
    rewrite ^/[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) /$1 last;
    rewrite ^/[_0-9a-zA-Z-]+/(.*.php)$ /$1 last;
    rewrite /. /index.php last; 
    
    location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location / {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^.+.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|av i|zip|gz|bz2?|rar)$ {
    root /var/www/bra1n/data/www/wyinc.ru;
    access_log /var/www/httpd-logs/wyinc.ru.access.log;
    error_page 404 = @fallback;
    }
    location @fallback {
    proxy_pass 46.4.67.247:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    }
    ==============

    2.2.4 Fourth version of the code

    =============
    }
    server {
    listen 46.4.67.247:80;
    server_name wyinc.ru www.wyinc.ru;
    rewrite ^(/manager/.*)$ https://$host$1 permanent;
    rewrite ^(/manager/.*)$ https://$host$1 permanent; 
    
    rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1; 
    
    if (!-e $request_filename) {
    rewrite ^.+?(/wp-.*) $1 last;
    rewrite ^.+?(/.*.php)$ $1 last;
    rewrite ^ /index.php last; 
    
    location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location / {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^.+.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|av i|zip|gz|bz2?|rar)$ {
    root /var/www/bra1n/data/www/wyinc.ru;
    access_log /var/www/httpd-logs/wyinc.ru.access.log;
    error_page 404 = @fallback;
    }
    location @fallback {
    proxy_pass 46.4.67.247:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    }
    ==================

    Positive results did not give any version

    Now displays an error message:
    =========

    Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects

    =========

    Также замечал, после какой-то из перезагрузок сервера такое сообщение:
    Also noticed after a some of reboot of the server, the following message:

    =========

    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    Please contact the server administrator, *****@*****.** and inform them of the time the error occurred, and anything you might have done that may have caused the error.
    More information about this error may be available in the server error log.
    ________________________________________
    Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny10 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g Server at wyinc.ru Port 80

    ============================

    I beg for your help!

    On the domain of more than 4,000 blogs - almost three days server is not working!

    Tell us where the errors?

    How to be in this situation, if using two servers(as I understood from the contents of the configuration file nginx.conf): nginx - as Frontend, and Apache - Backand.

  2. Problem #1: WordPress Multi User 2.7.1

    Problem #2: Nginx doesn't use .htaccess

    Why are you still one 2.7.1? 2.9.something is the end release of the separate install, and since 3.0, you just use WP standard. No one supports WPMU anymore.

    change the working mode of WP MU from "subdomains" to "subdirectory"
    that if visiter try to go to "blog1.mainsite.com", it will be redirect to "mainsite.com/blog1/" or "www.mainsite.com/blog1/"

    The basic concept is explained here: http://codex.wordpress.org/Multisite_Network_Administration#Switching_network_types

    But it's not going to be easy with 40,000 blogs, and you'll want to use this script - http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ - to search/replace the DB for the old URLs.

  3. freedom373
    Member
    Posted 1 year ago #

    Hello, Ipstenu (Mika Epstein)!

    Big Thanks, that you answer on my problem!

    ----------

    Why are you still one 2.7.1? 2.9.something is the end release of the separate install, and since 3.0, you just use WP standard. No one supports WPMU anymore.

    Thanks for the advice! Please, tell me how can I update my ver. 2.7.1 to 2.9 or 3.0. And what do You advice better to do: update to 2.9 or to 3.0. And how do I make this update correct ?

    Problem #2: Nginx doesn't use .htaccess

    Yes, I am understood this. Nginx has own rewrite directives, which contain in nginx.conf

    In our case, running a bunch of 2 servers (on hosting provider vps-server) nginx - as Frontend, and Apache - Backand.

    Please, can you advice, How to be in this situation ?

    Hosting provider is = Hetzner Online AG.
    Their support answer that: The configuration file /etc/nginx/nginx.conf should be in accordance with the configuration file /etc/apache2/apache2.conf.

    The basic concept is explained here: http://codex.wordpress.org/Multisite_Network_Administration#Switching_network_types

    As I wrote in my first post, I've read similar articles, of which I found some procedures for configuring WP MU + Apache + Nginx --- but something I do not correct, because I get in one case - Error 500 Internal Error, in other case -- Error 310 (net :: ERR_TOO_MANY_REDIRECTS): There were too many redirects or Internal Server Error.

    For recovery work of the domain = wyinc.ru we went back the old contents of nginx.conf (block of code, which refers to this domain)

    old code
    =========

    server {
    listen 46.4.67.247:80;
    server_name wyinc.ru www.wyinc.ru;
    rewrite ^(/manager/.*)$ https://$host$1 permanent;
    rewrite ^(/manager/.*)$ https://$host$1 permanent;
    location ~* ^/(webstat/|awstats|webmail/|myadmin/|manimg/) {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location / {
    proxy_pass 46.4.67.247:8080;
    proxy_redirect wyinc.ru:8080/ /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|av i|zip|gz|bz2?|rar)$ {
    root /var/www/bra1n/data/www/wyinc.ru;
    access_log /var/www/httpd-logs/wyinc.ru.access.log;
    error_page 404 = @fallback;
    }
    location @fallback {
    proxy_pass 46.4.67.247:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
    }

    =========

    But it's not going to be easy with 40,000 blogs, and you'll want to use this script - http://interconnectit.com/124/search-and-replace-for-wordpress-databases/ - to search/replace the DB for the old URLs.

    same correction: I have 4 thousands of blogs (not 40 thousands).
    Please, can You explain me for whatever reason, will need to make change in the database? and what do you mean = old URLs ?

  4. Thanks for the advice! Please, tell me how can I update my ver. 2.7.1 to 2.9 or 3.0. And what do You advice better to do: update to 2.9 or to 3.0. And how do I make this update correct ?

    Upgrade MANUALLY to MU 2.9.2

    Then manually upgrade to WordPress 3.0

    Then you can auto-upgrade to 3.5, though most people still want to do incrimentals.

    You can download all of these from here: http://wordpress.org/download/release-archive/

    Please, can You explain me for whatever reason, will need to make change in the database? and what do you mean = old URLs ?

    Old URL: subdomain.domain.com

    NEW URL: domain.com/subdomain

    Right? So you have to look for the OLD one and replace with the NEW one :)

  5. freedom373
    Member
    Posted 1 year ago #

    Upgrade MANUALLY to MU 2.9.2
    Then manually upgrade to WordPress 3.0
    Then you can auto-upgrade to 3.5,

    Thanks, I understood!
    I found recommendation article on how to do this upgrades:

    http://codex.wordpress.org/Upgrading_WPMU

    [1] Tell me, please, I must do all how it writes in it for get success result of upgrading or in articles subscribes not all points of "upgrade process"?

    though most people still want to do incrimentals.

    [2] Can You explain more detail this sentence? It means that not all people like upgrade to the most newer version (3.5)?

    --------------

    You can download all of these from here: http://wordpress.org/download/release-archive/

    Thanks!

    Old URL: subdomain.domain.com

    NEW URL: domain.com/subdomain

    Right? So you have to look for the OLD one and replace with the NEW one :)

    I understood. Yes, You are right!

    --------

    In our case, running a bunch of 2 servers (on hosting provider vps-server) nginx - as Frontend, and Apache - Backand.

    Please, can you advice, How to be in this situation ?

    Hosting provider is = Hetzner Online AG.
    Their support answer that: The configuration file /etc/nginx/nginx.conf should be in accordance with the configuration file /etc/apache2/apache2.conf.

    [3] It's very important for me, can You explain how I must right config this Server's configs for the joint to work properly both servers?

  6. I must do all how it writes in it for get success result of upgrading or in articles subscribes not all points of "upgrade process"?

    I'm sorry, I don't understand what youre asking.

    Can You explain more detail this sentence? It means that not all people like upgrade to the most newer version (3.5)?

    Incremental means people upgrade from version 3 to 3.1 to 3.2, instead of going from 3.0 to 3.5 directly.

    can You explain how I must right config this Server's configs for the joint to work properly both servers?

    I don't know at all the answer to this question either.

  7. freedom373
    Member
    Posted 1 year ago #

    I must do all how it writes in it for get success result of upgrading or in articles subscribes not all points of "upgrade process"?

    I'm sorry, I don't understand what youre asking.

    I mean that:
    This article http://codex.wordpress.org/Upgrading_WPMU is exist. In this article subscribe, how to do upgrades:
    1-step(from 2.7.1 to 2.8.3) + 2-step(from 2.8.3 to 2.9.x) + 3-step(from 2.9.x to 3.0)

    My question is whether all the items the update process for each of the steps (1-step, 2-step, 3-step) are described in this article, or maybe you can supplement each of the steps?

    ===========

    Incremental means people upgrade from version 3 to 3.1 to 3.2, instead of going from 3.0 to 3.5 directly.

    Thanks, I understood!

    ============

    can You explain how I must right config this Server's configs for the joint to work properly both servers?

    I don't know at all the answer to this question either.

    Ok, but You write at beginning of this topic that:

    Problem #2: Nginx doesn't use .htaccess

    and I have thought that You know this server and can explain how I can config it with Apache server.

  8. This article http://codex.wordpress.org/Upgrading_WPMU is exist. In this article subscribe, how to do upgrades:
    1-step(from 2.7.1 to 2.8.3) + 2-step(from 2.8.3 to 2.9.x) + 3-step(from 2.9.x to 3.0)

    My question is whether all the items the update process for each of the steps (1-step, 2-step, 3-step) are described in this article, or maybe you can supplement each of the steps?

    You're over thinking the process :)

    Do each upgrade one at a time. Step 1, then 2, and so on. Do them in order. Check that everything's okay as you go forward. You'll be fine.

    and I have thought that You know this server and can explain how I can config it with Apache server.

    No, I know how to make htaccess work, but not nginx which uses .conf files. And I don't know how to decode what you did in nginx to make that apache.

Topic Closed

This topic has been closed to new replies.

About this Topic