Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install Wordpress Multisite (Network) on a custom port

I'm running a website at http://localhost:8080/sitename. However, when I'm trying to create a network of sites with wordpress, I'm getting the following error under Tools-> Network:

ERROR: You cannot install a network of sites with your server address.
You cannot use port numbers such as :8080.

I tried to create a virtual host and a fake domain but I can't make it work. How can I solve that?

like image 239
MarcusV Avatar asked Jul 05 '12 16:07

MarcusV


People also ask

Why you should not use WordPress multisite?

Disadvantages of Multisite The things that make Multisite a great sharer also contribute to its flaws. Migrations are exceedingly complex as each site shares one database. Migrating one site off your network is very difficult. You cannot truly separate users; each one will still have access to the entire network.


2 Answers

At this moment, Wordpress only seem to support 80 and 443 ports. A temporary possible workaround to use any custom (i.e. http 8080) port:

  1. Open wp-admin/includes/network.php and find the section of code where it mentions array( ':80', ':443' ) and add :8080 too in that array.

  2. After completing setup of network, you might need in wp-config to adjust to such:
    define( 'DOMAIN_CURRENT_SITE', 'example.com'. (stristr($_SERVER['PHP_SELF'],'wp-login.php') ? '':':8080') );

  3. As noted in comments (thanks) after creating first sub-site, it might have port number embedded in domain name, so try to enter Mysql Database (i.e. try hosting's phpMyAdmin, or even installed plugin before starting procedure) and in _blogs & _site& _options tables, to adjust homepage urls of subsites(i.e. separate port number from domain).

  4. That's all. Login again to your project.

like image 184
user3665102 Avatar answered Oct 01 '22 04:10

user3665102


From my experience, WP is not designed to use custom ports for multi-sites so the blogs (sub-sites) hosts get messed up in the DB.

My solution: After you switch to multi-site or create a new site, you need to go to your db admin page (e.g. phpMyAdmin) and fix the blogs domain in the wp_blogs table. Basically WP failed to add a colon between the host and port; just have to add it-> localhost8080 becomes localhost:8080. So, on the site's settings add the missing colon to the siteurl and home urls.

like image 37
Arcanefoam Avatar answered Oct 01 '22 04:10

Arcanefoam