355968cf7f51fa3c05edbef9a2380b3343f1b46f
By:
kooperg

WP Multisite, different Domains, 1 Install

March 11, 2015 7.2k views
WordPress Ubuntu

I followed the guides, and now have Wordpress MU with 3 websites.
But, only the one I installed first works from it's own address at the moment.

The other 2 are stuck at xx1.website1.com and xx2.website1.com. They should be xx1.com and xx2.net.

I changed the apache config file, basically just added the same lines with different aliases. Added in sites-available for the 3 websites. did a2ensite and reloaded apache2.

Now, I changed the addresses in the WP MU install (mySites /networkadmin/Sites) to the correct url. But nothing is loading at that domain...

I don't know what step I missed, and can't find a guide on remapping domains on WP Multisite. Could anyone point me in the right direction?

7 comments
  • 
            # The ServerName directive sets the request scheme, hostname and port that
            # the server uses to identify itself. This is used when creating
            # redirection URLs. In the context of virtual hosts, the ServerName
            # specifies what hostname must appear in the request's Host: header to
            # match this virtual host. For the default virtual host (this file) this
            # value is not decisive as it is used as a last resort host regardless.
            # However, you must set it for any further virtual host explicitly.
            #ServerName www.example.com
    
    <VirtualHost *:80>
            ServerAdmin koopmanng@gmail.com
            ServerName xx1.com
            ServerAlias www.xx1.com
    
            DocumentRoot /var/www
            <Directory />
                    Options FollowSymLinks
                    AllowOverride All
            </Directory>
            <Directory /var/www>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride None
                    Order allow,deny
                    allow from all
            </Directory>
            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            # For most configuration files from conf-available/, which are
            # enabled or disabled at a global level, it is possible to
            # include a line for only one particular virtual host. For example the
            # following line enables the CGI configuration for this host only
            # after it has been globally disabled with "a2disconf".
            #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    
    
    
    
    
    
    ServerRoot "/etc/apache2"
    Mutex file:${APACHE_LOCK_DIR} default
    PidFile ${APACHE_PID_FILE}
    Timeout 300
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 5
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    HostnameLookups Off
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel crit
    IncludeOptional mods-enabled/*.load
    IncludeOptional mods-enabled/*.conf
    Include ports.conf
    
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        <Limit PUT DELETE CONNECT OPTIONS PATCH PROPFIND PROPPATCH MKCOL COPY MOVE LOCK U$
            deny from all
        </Limit>
    </Directory>
    
    <Directory /var/www>
            Options FollowSymLinks
            AllowOverride FileInfo
    </Directory>
    
    <Directory /usr/share>
            AllowOverride All
            Require all granted
    </Directory>
    
    AccessFileName .htaccess
    
    <FilesMatch "^\.ht">
            Require all denied
    </FilesMatch>
    
    
    AccessFileName .htaccess
    
    <FilesMatch "^\.ht">
          Require all denied
    </FilesMatch>
    
    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_$
    LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %O" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    
    IncludeOptional conf-enabled/*.conf
    IncludeOptional sites-enabled/*.conf
    
    #<DirectoryMatch ^.*/wp-content/uploads/>
    #  AllowOverride All
    #  php_flag engine off
    #  php_admin_value engine Off
    #</DirectoryMatch>
    
    #<DirectoryMatch ^.*/wp-content/blogs.dir/>
    #  AllowOverride All
    #  php_flag engine off
    #  php_admin_value engine Off
    #</DirectoryMatch>
    
    #<DirectoryMatch ^.*/wp-admin/>
    #  AuthType Basic
    #  AuthName "Welcome Gijs!"
    #  AuthUserFile /etc/apache2/.htpasswd
    #  Require valid-user
    #</DirectoryMatch>
    
    <VirtualHost *:80>
       ServerAdmin info@
       DocumentRoot /var/www
       Servername 104.236.227.62
       ServerAlias website1.com www.website1.com
     </VirtualHost>
    
    <VirtualHost *:80>
       ServerAdmin koo
       DocumentRoot /var/www
       Servername 104.236.227.62
       ServerAlias www.xx1.com xx1.com
    </VirtualHost>
    
    <VirtualHost *:80>
       ServerAdmin info@
       DocumentRoot /var/www
       Servername 104.236.227.62
       ServerAlias www.xx2.net xx2.net
     </VirtualHost>
    
    
  • 
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    
    
    <?php
    /**
     * The base configurations of the WordPress.
     *
     * This file has the following configurations: MySQL settings, Table Prefix,
     * Secret Keys, and ABSPATH. You can find more information by visiting
     * {@link http://codex.wordpress.org/Editing_wp-config.php Editing wp-config.php}
     * Codex page. You can get the MySQL settings from your web host.
     *
     * This file is used by the wp-config.php creation script during the
     * installation. You don't have to use the web site, you can just copy this file
     * to "wp-config.php" and fill in the values.
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    
    /** MySQL database username */
    
    /** MySQL database password */
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/s$
     * You can change these at any point in time to invalidate all existing cookies. This$
     *
     * @since 2.6.0
     */
    
    /**#@-*/
    
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each a unique
     * prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix  = 'wp_';
    
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     */
    define('WP_DEBUG', false);
    
    
    define( 'WP_ALLOW_MULTISITE', true );
    
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'rinconolon.ec');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
            define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    define('FS_METHOD', 'direct');
    define('AUTH_KEY',         'Gt-$ZV!GbP{Xo+]MU<heSz Vt}K>T.fp=$=T1Qz8;Xp;$f6.d(]yj&eo,$
    define('SECURE_AUTH_KEY',  'T%pl`8*;)!|Rv|+M:E4,&%m?*]|MWr&$e`]P-]p|mr|tU_MpM?#4&tKkw$
    define('LOGGED_IN_KEY',    'N](HwTmt+;ub]<E+vl|I#o;dHjAN4<z]}kkN/B0+ck#PPh!QF%j/!]T=_$
    define('NONCE_KEY',        '?l5$9=32Gc%xjfv)J|hUCcJpdO~A*-j`_D+.xFk;GsazRzK2G|OkFUcJY$
    define('AUTH_SALT',        'Q?D*wl_UX+UgAe|0{OBT+U<qeeB&h,G7;A%V?=!N|W)@_9K0Rf2&t]0Q~$
    define('SECURE_AUTH_SALT', 'h:^U=>!m0>r8K1R*3Uj-$|^EDU -o?[#>i$6ce<ph{}0jXQCC|jiPo{!X$
    define('LOGGED_IN_SALT',   'u(:>jw|[._.}A;+CDa%e+JeHv&#&g8frq2+{~!QI%zvw[_ODbnlLB0C-@$
    define('NONCE_SALT',       'sbx~#`(kwyMwt@R?|,&qJo|cP$!2{w,<0|z7WVMG<!E[!Bu1R_UG4,yxB$define('DB_NAME', 'wordpress');
    define('DB_USER', 'wordpress');
    define('DB_PASSWORD', '2Ih3ZtiRhK');
    define( 'SUNRISE', 'on' );
    require_once(ABSPATH . 'wp-settings.php');
    
    
    
  • It seems my perma-links are not working... So something went wrong somewhere...

    All info (htaccess, wp-config, 000-site.conf, apache2.conf) are pasted below.

    Many thanks to anyone that's able to point me in the right direction!!!

  • Set the AllowOverride directive inside every <Directory /var/www> block to All.

    <Directory /var/www>
    [...]
    AllowOverride All
    [...]
    </Directory>
    

    The vhost file meant for this Multisite setup should have all the domains in `ServerAlias.

    ServerName website1.com
    ServerAlias *.website1.com xx1.com xx2.net
    

    Ensure mod_rewrite is enabled:

    sudo apachectl -M | grep rewrite
    

    If not enable it:

    sudo a2enmod rewrite
    sudo service apache2 reload
    
  • It's still only the first website that is showing...

    I now have 3 .conf files in sites-available:

    000-default.conf that has all the sites in the ServerAlias and the main website as the ServerName (NOT the IP adress as I had put before)

    000-xx1 for my second site just has that sitename as ServerName and ServerAlias
    000-xx2 for my thirds site just has that sitename as ServerName and ServerAlias

    I made sure to put all the AllowOveride All in all the instances I found it

    I changed the apache2.conf file as well, it's like this now (ServerName = website name, not the IP adress)

    
    <VirtualHost *:80>
       ServerAdmin info@
       DocumentRoot /var/www
       Servername website1.com
       ServerAlias website1.com www.website1.com
     </VirtualHost>
    
    <VirtualHost *:80>
       ServerAdmin koo
       DocumentRoot /var/www
       Servername xx1.com
       ServerAlias www.xx1.com xx1.com
    </VirtualHost>
    
    <VirtualHost *:80>
       ServerAdmin info@
       DocumentRoot /var/www
       Servername xx2.net
       ServerAlias www.xx2.net xx2.net
     </VirtualHost>
    

    I also encountered this in the apache2.conf file. Is this the correct setting?

    HostnameLookups Off
    

    Then I restarted Apache, but still nothing. Mod rewrite was enabled already.

    Do I need to fill in the site URL in wordpress 'SITES' now, instead of the subdomain it's parked at now? Or what is the next step to check?

  • I added the wildcard for my main domain name to the 000-default.conf and apache2.conf

    restarted apache2, still nothing

    Also tried to input the correct domain names for the 2 sites in the SITES part of the WP Multisite admin.

    Still not working. In the mean time, the permalinks are back on, thank god (was probably the AllowOverride All part, of course).

    Is there anything I need to mention in any of the files to point the sites to a specific directory? They all point to /var/www now, is Wordpress supposed to figure the rest out by itself?

    I'm a bit lost.. .Should I consider transferring everything to Nginx...?

7 Answers

You may want to change your WP DB password and username as you made it public here.

I guess I need Nginx to do this, and cannot simply change some apache2 files... Didn't know that!

no, Apache will work fine. I have set it up several times for Wordpress Multisites.

But go ahead and try Nginx and see if you can get further along. There are a couple of other things I can suggest if you are still having problems.

btw: are you using a plugin to map domains in Wordpress Multisites? If not, you need to add each domain to the database under wp_sites table.

  • Dude, thanks ever so much!!!! I had a typo in my DNS records for both sites!!! THANKS!!!!

  • Hi mate, everything works perfectly now, thanks so much!!!
    One more major mistake I made was, at the Domain settings of the plugin, I put the url with http:// which resolved to http://http//mysite.com

    But mostly it was because i had put 204.xxx.xxx.xx instead of 104.xxx.xxx.xx in the 2 new sites DNS :D

thanks mate! I'm learning every second... Done now :)

The wp-config.php is the only place I need to put the new password, right?

I'm doing this guide now to see if it gives me domain mapping superpowers :)

https://www.digitalocean.com/community/tutorials/how-to-set-up-wordpress-multisite-with-nginx-on-ubuntu-14-04

I guess I need Nginx to do this, and cannot simply change some apache2 files... Didn't know that!

by Jesin A
This tutorial will show you how to set up WordPress Multisite with subdomains on an Nginx web server. This allows you to run multiple unrelated websites, with their own domains, from a single WordPress admin panel.

edit: yes, I have WordPress MU Domain Mapping installed.

And I tried auto-fill the Site ID number... I have them as 2 for the second site and 3 for the 3rd site.. Can I find the correct Site ID anywhere..?

yes, i do have the plugin... But you make a very very good point.

My domains do not go to my website... at all

Let me see what I can do about that....

  • if you just now made changes to your DNS records, be patient..it can sometimes take a bit for those changes to start showing up properly.

    You can test by pinging your domain..it should return your droplet ip or name

If anyone sees this, I somehow switched to Nginx by doing half the tutorial... I never activated it nor deactivated Apache... Is this going to be a problem in the future? Do I simply not use Apache anymore now, or is it still needed/used for something?
Thanks

(I found out when uploading sitemaps... then I thought I would deinstall Nginx, which resulted in all the sites going down :D So happy removing Nginx does not remove its settings!! :D)

  • You should probably remove Apache since it will be using resources running in the background:

    sudo apt-get remove apache2

    if things break, you can just reinstall like you did with nginx

cool, nothing broke! :) thanks a lot mr Sierracircle! :)

Have another answer? Share your knowledge.