chlee
Posts: 2
Joined: Wed Jan 02, 2019 9:46 am
Location: Germany

How to set 2 wordpress sites on a RPi with different domain names

Wed Jan 02, 2019 10:14 am

Hello everyone,

I am running one wordpress site well, by using LAMP and a free no-ip ddns which is easily to visit from public network because I don't have fixed ip address.
Now I am planing to have another wordpress site for different topic but have no idea how to set it.

I don't want to be known that these two sites are written by the same person, so two sites in different directory but using the same domain may not be a solution for me.
I would like to use different domain names when visited from public network. That means I may have to set 2 ddns.
But my router (I am using fritzbox) seems only to allow one ddns to each intranet ip address, not to each port.
Does that mean that my RPi, which has one address in intranet, can only use one ddns at same time?
Do I have to buy one more RPi to fulfill my need?

Could anyone share opinions or guideline?

Thanks a lot.

Regards

epoch1970
Posts: 3109
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to set 2 wordpress sites on a RPi with different domain names

Wed Jan 02, 2019 10:32 pm

You can give multiple ip addresses to an interface. I don’t know how you do that in dhcpcd.conf, I suggest not doing it old style with an “alias” in /etc/network/interfaces
But basically from the command line, something like “ip address add 192.168.1.5/24 brd 192.168.1.255 dev eth0” would add another address to eth0.
If you “ifconfig eth0” you’ll only see one address, but “ip address show eth0” will show all addresses assigned to the interface.

A useful “ip” how-to: https://baturin.org/docs/iproute2/
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
WillBoxOwO
Posts: 116
Joined: Wed Jun 27, 2018 10:24 pm

Re: How to set 2 wordpress sites on a RPi with different domain names

Thu Jan 03, 2019 1:37 am

You could open the first website to port 80 and the second one on port 81. It would then give you something like this:

port 80: yourwebsite.com
port 81: your-other-domain-name.com:81

Both websites should points to your IP adress.
I like cats

gkreidl
Posts: 5957
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: How to set 2 wordpress sites on a RPi with different domain names

Thu Jan 03, 2019 7:09 am

The fritzbox (or any other router) does port forwarding, not domain forwarding. But it can only update one DDNS account. You have to run a small script which updates your second domain DDNS.

Then you can set different directories within your web server configuration to handle different domain names.

I used to have 5 DDNS accounts and used them for different services / websites.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

chlee
Posts: 2
Joined: Wed Jan 02, 2019 9:46 am
Location: Germany

Re: How to set 2 wordpress sites on a RPi with different domain names

Thu Jan 03, 2019 10:12 am

Thank you all.

I answered myself after got a simpler solution..

Now WP has new features for multi-sites.
It appropriates not only sub-folder structure, but also with different domain name.

Just set the new site URL as a sub-folder under main site first then re-set it again to another URL (e.g. No-IP ddns which I am using).
It works like two independent sites and more flexible because you can use one network admin to manage all sites.

https://codex.wordpress.org/Create_A_Network

bzt
Posts: 374
Joined: Sat Oct 14, 2017 9:57 pm

Re: How to set 2 wordpress sites on a RPi with different domain names

Thu Jan 03, 2019 11:29 am

Hi,

Just for the records, the proper solution here is using name-based virtual hosts. In the HTTP Request header, there's a "Host" field. This vhost module connects different configuration blocks according to the value of that "Host" field. Thus, you can have one DocumentRoot when your webserver is called with "abc.tld" domain, and another one when called with "def.tld". You can install WP in both DocumentRoots, but you can also use a different framework in one of them if you'd like. With this, you can have a different versions of WP or different set of plugins for both websites.

I think this sound more complex than it is, take a look at the example:

Code: Select all

Listen 80
<VirtualHost *:80>
    ServerName abc.tld
    DocumentRoot "/var/www/abc"
</VirtualHost>

<VirtualHost *:80>
    ServerName def.tld
    DocumentRoot "/var/www/def"
</VirtualHost>
First we tell apache to listen on port 80. Then we create two configuration blocks, in which the "ServerName" tells which one to apply when a certain HTTP Request is made. You can use more configuration directives in those blocks of course.

Because of the huge resource requirements of apache, I do not suggest LAMP on an RPi. I think nginx is much better choice for the job (also installable from the raspbian repository). It is capable of serving virtual hosts, eg. assigning different configuration blocks according to the requested domain name. Setting up PHP is a bit trickier with it though, you'll need to install php-fpm, but the result worth the effort imho.

Cheers,
bzt

Return to “Networking and servers”