WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Network installaion with SubDomains on XAMPP (9 posts)

  1. shastaw
    Member
    Posted 2 years ago #

    I'm trying to create an identical copy of my live site on my local server so I can use it for development. I installed XAMPP (on Win7). I can get WordPress running, but as soon as I try to set it up as a network install it fails. (I'm also building the database by importing the backup from the live site, if this matters.)

    I've double checked that wp-config.php has the correct database values, changed the server to localhost, etc., the user has all permissions, etc. But as soon as I try to install a subdomain based network I get this:

    Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

    I'm fairly sure this has to do with settings in Apache I may need to configure, but I'm not finding any tutorials about installing networks on localhost. I did find references to the requirement that wordpress be installed at the root, and I'm wondering if installing it here:

    C:\xampp\htdocs\mywordpress

    is the problem. That maps to localhost/mywordpress, which isn't exactly root, but I'm not sure what the equivalent of root would be for my localhost installation. I'm guessing that may be an apache configuration too...

    Can anyone point me to a tutorial, resources, or otherwise help me move forward on this project?

    [moved to Localhost install forum]

  2. Samuel B
    moderator
    Posted 2 years ago #

  3. shastaw
    Member
    Posted 2 years ago #

    Thanks. That was useful, but it was missing a key fact that had me running in circles for many hours: when you create virtualhosts you need to add an entry for localhost or you'll clobber it. I initially added this:

    <VirtualHost *:80>
      ServerName testsite.com
      DocumentRoot "C:/xampp/htdocs/testsite"
     DirectoryIndex index.php index.html index.htm
    </VirtualHost>

    My XAMPP landing site at localhost stopped working. Since my WordPress installation wasn't working, I didn't realize for some time that what I'd basically done is said "anything going to port 80, please send it to this directory."

    I figured it out with help from this Apache page:
    http://httpd.apache.org/docs/2.2/vhosts/name-based.html

    I also found this discussion understandable:
    http://sawmac.com/xampp/virtualhosts/?phpMyAdmin=K85PsD36cqNo3YRTvysYodEi0lb

    Adding an entry for localhost got me back to a functioning XAMPP page:

    <VirtualHost *:80>
      ServerName localhost
      DocumentRoot "C:/xampp/htdocs/xampp"
     DirectoryIndex index.php index.html index.htm
    </VirtualHost>

    Then I moved everything (WordPress) out of the folder testsite.com points to and put a plain old index.html Hello World. Apache properly directs testsite.com to that page now.

    However, when I put the WordPress files back in and go to testsite, I redirect here:

    http://localhost/testsite/wp-signup.php?new=testsite.com

    and I get an "object not found" error. At this point I'm pretty sure I'm back firmly on to "your WordPress is not configured correctly" territory. Any tips?

  4. shastaw
    Member
    Posted 2 years ago #

    The redirect was because I'd forgotten to update the 1p-config.php file from the live site (I'd done a fresh download along the way...)

    I'm back to "The page isn't redirecting correctly". If I replace the wordpress installation with a static index.html page in the testsite folder, I can get to it with testsite.com, so I think the server configuration is now correct, so it's probably WordPress now, right?

    Can anyone help me? I'm going on day five trying to install locally, and the online directions seem very sparse for 3.0 with network, so I'm going to document everything I can think of:

    I have this config:

    In my hosts file on my Win7 machine:
    127.0.0.1 testsite.com

    In my httpd-vhosts.conf for Apache:

    NameVirtualHost *:80
    
    <VirtualHost *:80>
      ServerName testsite.com
      DocumentRoot "C:/xampp/htdocs/testsite"
     DirectoryIndex index.php index.html index.htm
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerName localhost
      DocumentRoot "C:/xampp/htdocs/xampp"
     DirectoryIndex index.php index.html index.htm
    </VirtualHost>

    In my wp-config.php file:

    define ('WPLANG', '');
    define( 'COOKIEPATH', '/' );
    define('WP_ALLOW_MULTISITE',true);
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', true );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', 'testsite.com' );

    .htaccess file in "C:/xampp/htdocs/testsite": (unchanged from livesite)

    # BEGIN WordPress
    #<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    #</IfModule>
    
    # END WordPress
  5. shastaw
    Member
    Posted 2 years ago #

    Well, I have more things working:
    [spaces are to prevent those URLS from linking]

    http:// testsite.com works.
    http:// user1.testsite.com/wp-admin pages work too.

    But as soon as I try to go to http:// user1.testsite.com/ I get redirected to http:// user1.site.com (the online live version.)

    There must be a configuration hidden somewhere, but I can't seem to find it. I tried a search and replace on an export of the database, but couldn't re-import it, so I've manually updated the database tables wp_blogs, wp_site, wp_#_options, wp_sitemeta to eliminate mention of site.com

    The .htaccess file also says define( 'DOMAIN_CURRENT_SITE', 'testsite.com' );

    Any hints? This must be getting specific enough to sound familiar to someone...

  6. shastaw
    Member
    Posted 2 years ago #

    I've done more research...there is clearly a "site.com" hiding in the configuration somewhere, as the wp_head and menu hooks are spitting out links with site.com even though the site_URL is correctly set to testsite.com

    I've manually inspected/updated the wp_blogs, wp_site, wp_#_options (where # is the subdomain blog I'm testing with), wp_sitemeta and wp_posts tables to eliminate mention of site.com

    [It seems to me I should not have to update the GUID for posts, but as a test I did do that -- seemed to make no difference.]

    I now have a localhost site which will function correctly as long as I type in every URL I want to visit. However the links on the page are being generated incorrectly.

    Can anyone tell me where else to look?

  7. shastaw
    Member
    Posted 2 years ago #

    All right..another increment of progress. I'd missed one of the site.com in the options table. With that fixed, I can now use every link in the subsite EXCEPT the home link.

    So this works:
    <a href="http://user1.testsite.com/comments/">Comments</a>
    
    But this redirects to the live site.com:
    <a href="http://user1.testsite.com/">Home</a>

    At this point I'm mainly documenting for the next poor fool who tries to do this, but I may as well post as I go in case anyone is listening...I'll also post a followup with all the things I learned when I finally get it working.

  8. shastaw
    Member
    Posted 2 years ago #

    And it WORKS! In case anyone else is trying to install WordPress 3.x+ with subdomain network on localhost for testing, here are the steps:

    1) install XAMPP. Make sure you can get to http://localhost
    2) manually unpack WP files into C:\xampp\htdocs\yoursite or equivalent. Do NOT run the installer!
    3) export the database from your live site and download it.
    4) import that database using phpMyAdmin (http://localhost/phpmyadmin/)

    You're going to need a *different* domain from your live site, so your browser can tell them apart. I called my local test site testsite.com

    5) Edit these entries by changing site.com to testsite.com (or whatever you chose): WP_SiteMeta.siteurl, WP_Site.domain, WP_Options.home, WP_Options.siteurl, WP_Options.fileupload_url, WP_Blogs.domain

    Then for EACH blog edit
    WP_x_Options.home, WP_x_Options.siteurl, WP_x_Options.fileupload_url , where x is the number for that blog.

    [Note: if you changed the prefix for security, it might not be WP_ . Also, in theory you should be able to do a replace on the whole thing, but my import failed when I tried.]

    6) edit the wp_config.php file to reflect the connection to your database and the new domain you've assigned the site.

    7) now we need to add a virtual host entry to our localhost server. In my version of Apache that file is here:

    C:\xampp\apache\conf\extra\httpd-vhosts.conf
    
    and I add this:
    
    <VirtualHost *:80>
      ServerName *.testsite.com
      DocumentRoot "C:/xampp/htdocs/site"
      DirectoryIndex index.php index.html index.htm
      ServerAlias *.testsite.com
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerName localhost
      DocumentRoot "C:/xampp/htdocs/xampp"
     DirectoryIndex index.php index.html index.htm
    </VirtualHost>

    You'll need to restart Apache now.

    8)Finally I add entries to my hosts file so my browser knows where to go when I type in something.testsite.com:

    `127.0.0.1 testsite.com
    127.0.0.1 user1.testsite.com'

    [Note: I thought you could use *.testsite.com, but it doesn't work. This means you have to add an entry for each blog, which is sub-par. Anyone know if there's a way around that?]

    On Win7 the hosts file is here: C:\Windows\System32\drivers\etc\ . Windows will try to protect you by hiding the etc directory and preventing saves to the hosts file. Right click your text editor and "run as admin" then type the address in and you'll be able to open and save hosts.

    (HINT: you can redirect sites your teen is grounded from by listing their IP here with a redirect to something else. I like "mother is watching" Bonus points for a hit-counter displayed on the page. ;-) )

    In theory it should all work now. Hahaha. I started this process a week ago, so there's a decent chance I've forgotten some detail, but hopefully this will help you get closer faster.

  9. shastaw
    Member
    Posted 2 years ago #

    This thread has a useful comment regarding how to name the local network: http://wordpress.org/support/topic/subdomains-on-localhost

    (Trying to collect instructions in one place in the hopes it's useful to someone.)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.