Search code examples
wordpressmampmultisite

How do I setup an existing Wordpress site to use multi-site feature on a local computer using mamp


I backed up my existing Wordpress site to work on it locally to create a multi-site network. My goal is not only to leave the existing site as-is, but add a new homepage with its own theme. I am trying to create a multi-site within a sub-folder.

I got it to work with a fresh install of Wordpress however I've run into complications with an existing local site.

Steps I've taken:

  • I changed the .htcaccess file to:

    # BEGIN Wordpress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    # END WordPress
    
  • I've changed the ports from :8888 & :8889 to :80 & :3306

  • I've changed the host file within the terminal with the command:

    sudo nano /etc/hosts
     127.0.0.1         vslocal.com
     127.0.0.1         sub.vslocal.com
    
  • I performed a search and replace within the database with the new domain for the local site.

  • I changed the wp-config.php file to include:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', vslocal.com');   
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);  
    define('BLOG_ID_CURRENT_SITE', 1);
    

Now I am receiving the "Error establishing a database connection" error. After following different resources I might have confused myself and I'm having trouble with what steps have I missed or done incorrectly. I am running on a Mac OSX Yosemite and using MAMP 2.2. Any help will be a lifesaver! Thanks!


Solution

  • Beside configuration syntax errors, actually i did multisite migration from server to server successfully, Below is the steps I've taken that will work properly.

    1.migrate multisite files and complete sql from sever A to sever B(localhost); 2.change the db-config php to enable new db connections and the domain changes u've done. 3.Before changing the sqls, You would still see “error connecting with db". (but if u remove the .htaccess or disable it , the db connection falure message will be gone.so it's just means multisite sql migration not fully correct.) search and replace sql strings, make sure newurl replaces oldurl within all sites’ option tables, blog table and site table etc.

    So i guess maybe the db connection failure error has something to do with your sql replacement.