[resolved] One blog, multiple (virtual) servers (5 posts)

  1. WillemGrooters
    Posted 3 years ago #

    I have one WP instance that I want to access using different webserver/virtual hosts, listening of different ports: one listens on port 80, second on 81, third on 82 and so on. So to access the blog, the URL would be http://host:port/blogname.
    Problem though is that WP stores WP- and blog URLs in the database (table <prefix>_options, and in order to have the instance work with one particular server, it needs to hold the port-number as well - as I found out.
    Can it be done?
    It would be nice it that could be retrieved by the WP code from the URL, but if I would need to set a variable per server, that would be a possibility as well, and add that in the URL when needed

  2. Shaun Scovil
    Posted 3 years ago #

    Seems like a strange configuration you're going for...which begs the question: Is there a more orthodox way of achieving the desired effect?

    For example, would port forwarding or a multisite installation do the trick?

  3. WillemGrooters
    Posted 3 years ago #

    I have reasons for this: this configuration is used to compare different server configurations, or even completely different web servers (a facility I have on my OS of choice), and therefore the only difference should be the server by which the application (in this case WordPress) is accessed. And each of these will access the application over it's own port. B ecause that port is kept in the URL stored in the database, it is limiting access over that port only. I have observed that when port 81 is defined, access over port 82 will start the access, but the server on port 81 will take over at some point, and some functionality does not work...Different blogs (no problem for me - because the OS) using one database is no option either - for the same reason: the URL stored in the database will limit access over that single port....
    So port forwarding nor mutisite installtion will do the trick...

  4. Both the home and site url values are also definable via PHP constants. So if you have a means in PHP available to detect which server is being accessed, then you can change those values dynamically by setting varying constants for them. Setting constants will cause WordPress to ignore the database's settings for those values.

    So something like this at the top of the wp-config.php file, for example:

    if ( $_SERVER['SERVER_PORT'] == 81 ) {
    else if ( $_SERVER['SERVER_PORT'] == 82 ) {

    ... and so on.

  5. WillemGrooters
    Posted 3 years ago #

    Thanks, that's just what I was looking for :)

Topic Closed

This topic has been closed to new replies.

About this Topic