Hosted two websites on same bitnami server

Keywords: WordPress - Linux - How to - Other
Description:
hello,

I have a bitnami server and I want to host 2 website on the same server…

in htdocs - root folder for bitnami , I have created two directories and inserted the websites files in each directory.

Is this all i need to do ?? when I click the URL for the first website from the browser, how will the server direct the request to the correct website directory in htdocs?

here is the two directory for the two websites, each directory contains the wordpress files related to the website

Hi @ghina.altal,

This section of our documentation explains how to deploy a custom PHP application in your LAMP instance, could you please take a look at it and ask us any questions you have?

https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/

Thanks

Hello @jota I read it but still some point not clear…

1.what about the database? how to implement them
2. if I want to access the websites from the internet how to should that be done? do I need to change the v host fileor something like that?

as my scenario is:

I want to deploy two wordpress websites with their database on the bitnami server, and I want to access them from the internet.
www.firstsite.com
www.second site.com

Where to put the files of each website ( the path on server)? how to create database for each one ? and how can I access them from the internet using their URL?

Hi @ghina.altal

it’s also documented in our guides

https://docs.bitnami.com/aws/infrastructure/lamp/configuration/create-database/

Why don’t you use our WordPress Multisite solution? It allows you to deploy multiple WordPress sites.

https://docs.bitnami.com/aws/apps/wordpress-multisite/get-started/understand-wordpress-multisite/

Please note that if you use the Bitnami WordPress Multisite solution, the installer / deployment will take care of creating the different databases and configuring the application for you to start to use it.

@jota … In case I used this scenario Hosted two websites on same bitnami server

I want to know how can I map the domin names to the server IP?

If I put website1 folders in /opt/bitnami/apps/demo/htdocs
and the 2nd website folders in /opt/bitnami/apps/demo2/htdocs

I want to access the sites from intrnet like this:
www.site1.com
www.site2.com

how can I do that? I mean mapping the same server IP to these two directories ?
is it like that:
mapping the same server IP to www.site1.com and www.site2.com

Hi @ghina.altal,

This guide explains how to configure a virtual host in the application. The httpd-vhosts.conf file is included inside the apps/demo/conf folder.

https://docs.bitnami.com/aws/apps/wordpress/administration/redirect-custom-domains/

Please note that you will also need to generate valid certificates (o copy the ones in /opt/bitnami/apache2/conf) in the apps/demo/conf/certs folder so you can use https when using those domains.

Let us know if you have any questions

Hi @jota I did not get it, the documentations are not clear …
could you write out the steps for my scenario above …
thank you…

Hi @ghina.altal,

Before providing you the steps to configure the applications, I’d need to review your current configuration first.

We have a Support Tool that will gather relevant information. Could you please download and execute it on the machine where the stack is running by following the steps described in the guide below?

How to Run the Bitnami Support Tool

Please note that you need to paste the code outputted by the tool in your reply.

Hi @jota

here is the requested code:
a824b58a-529b-8e95-3ec4-ea12ccf56eed

please I need to know a clear steps to implement two WordPress websites and access them form internet using their domain name … for example …

www.site1.com
www.site2.com

I need to know:

  1. where to put the wordpress files for website1 and website2 ?
    as in case on one website I cant put it in the root directory ( htdocs) but what about two websites??

  2. how to make the first and second domains mapping to the same server IP???
    www.site1.com
    www.site2.com

your documentations are not clear enough and doesn’t show how to do that in clear way…
there much be a full documentation scenario for such case, showing up the implementation of more than 1 website on bitnami and how to map the domains to same IP and create the data bases…

much appreciated…

Hi @ghina.altal,

Thank you for the information. Before sharing with you any command I want to let you know that we have WordPress module installers that take care of installing WordPress only and you can configure different folders for the different installations.

You can run these commands and they will install 3 different wordpress in the apps folder:

cd /tmp
wget https://downloads.bitnami.com/files/stacks/wordpress/5.0.3-2/bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run
chmod +x bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run
sudo ./bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run --wordpress_instance_name testatc
sudo ./bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run --wordpress_instance_name testdo
sudo ./bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run --wordpress_instance_name yasholding

After running those commands, you will be able to access them using yourIP/testatc, /testdo or /yasholding. Once you confirm that this works, we will let you help you to configure the Virtual Hosts so you follow the Bitnami standards instead of creating different folders in the apache2/htdocs folder that would be difficult to configure.

In case you already have some information in the demo sites you deployed, you could back them up using the All in One WordPress migration plugin and recover them later

https://docs.bitnami.com/installer/how-to/migrate-wordpress/

Thanks.

1 Like

@jota … Can I do Virtual Hosts for the fles on htdocs ???
testdo test atc and testyas ???

Yes @ghina.altal,

You could copy the default virtual hosts blocks inside the apache2/conf/bitnami.conf file but you will need to perform multiple changes in those new virtual hosts. For example, they include the information of other files that you don’t need to include and apart from that, you will also need to configure the DocumentRoot and Directory parameters to properly serve the applications you have in those folders.

The approach I mentioned above will be easier to configure. Once you install the different modules, you will need configure the VirtualHosts for the different application but as they follow the Bitnami standards you will only need to follow our documentation and generate the certificates you want to use

Hi @jota … as for the above documents , I din’t want to use the all in one migration plugin …
I already have the wordpress folders and want to put them in the correct path!

Till now I don’t have a clear steps for that … your documents are not clear and stuck with one solution…

I need a clear steps how to implement three websites and access them from internet using their domain name, could you please provide a clear steps without referring back to your documentations as they are written for general case?

Hi @ghina.altal,

I think we are messing this thread with different topics. Please, first answer the questions below so we can get a better understanding of your problem.

  • Did you installed the Bitnami WordPress modules that @jota mentioned in his previous post?
  • Have you already modified anything in your server? If so, what?

Also, in one of his previous post, @jota mentioned about using WordPress Multisite for hosting multiple WordPress sites using different domain names for each site in the same server. Another option is manually installing multiple Bitnami WordPress modules.

Please let us know which option do you want to follow. In my opinion, the easier one is using WordPress Multisite.

Regards,
Gonzalo

I have bitnami-LAMP server. in the root directory of the server ( htdocs) , I create three sub directories as follows:

image
each directory contains the website files as:

image

I can access them in browser by typing server IP/ directory name, for example localhost/ww1.testatc.co.ae
and it works.

now I need to implement mapping for these hosted domains.
I want to access these websites from internet using their domain names … how can I implement that??

regarding the server…no I didn’t change any thing …

can you help me in that scenario … I already did this and don’t want to go with the other scenarios mentioned in ur documentation as I already put the files in the following paths.

Thank you.

Hi @ghina.altal,

We suggest you follow the way to configure the sites as I mentioned above because you will follow the Bitnami standards. In case you don’t want to follow our suggestions, you can follow these steps:

  • In the /opt/bitnami/apache2/conf/bitnami/bitnami.conf file, you can find the default VirtualHosts blocks of Apache. You can edit that file and include new VirtualHosts blocks per directory and per Apache’s port (80 and 443 port).

  • Inside the default VirtualHosts, we include the configuration of other files, you will need to remove that “Include” line and include the information you want to use in your WordPress.

This is an example

<VirtualHost *:80>
    ServerName ww1.testatc.co.ae
    DocumentRoot "/opt/bitnami/apache2/htdocs/ww1.testatc.co.ae"

<Directory "/opt/bitnami/apache2/htdocs/ww1.testatc.co.ae">
    Options +MultiViews +FollowSymLinks
    AllowOverride All
    <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>

    RewriteEngine On
    #RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [S=1]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
</Directory>

</VirtualHost>

This code should work to configure the virtual host for the first app. You will need to create another one for the 443 port. As I mentioned above, this doesn’t follow the Bitnami standards. You will need to deal with the configuration and ask us any questions you have when configuring it.

Hi @jota

Ok I want to follow Bitnami standers , can you give clear steps for that…

in Which path sould I put the folders and how to configure V host for them ???

Ok @ghina.altal,

Let’s start with the installation of the WordPress modules

cd /tmp
wget https://downloads.bitnami.com/files/stacks/wordpress/5.0.3-2/bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run
chmod +x bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run
sudo ./bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run --wordpress_instance_name testatc
sudo ./bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run --wordpress_instance_name testdo
sudo ./bitnami-wordpress-5.0.3-2-module-linux-x64-installer.run --wordpress_instance_name yasholding

After that, check that you can access those applications using yourIP/testatc, yourIP/testdo adn yourIP/yasholding. Those applications are empty so you will need to move the content of the current installations you have in htdocs to those folders

sudo mv /opt/bitnami/apps/testatc/htdocs /opt/bitnami/apps/testatc/htdocs.back
sudo mv /opt/bitnami/apps/testdo/htdocs /opt/bitnami/apps/testdo/htdocs.back
sudo mv /opt/bitnami/apps/yasholding/htdocs /opt/bitnami/apps/yasholding/htdocs.back
sudo cp -rp /opt/bitnami/apache2/htdocs/ww1.testatc.co.ae /opt/bitnami/apps/testatc/htdocs
sudo cp -rp /opt/bitnami/apache2/htdocs/ww1.testdo.ae /opt/bitnami/apps/testdo/htdocs
sudo cp -rp /opt/bitnami/apache2/htdocs/ww1.yasholding.ae /opt/bitnami/apps/yasholding/htdocs

Ensure now that you can access all the information you had in your previous installations using the /testatc, /testdo and /yasholding. You could remove the apache2/htdocs folder once you confirm that everything works as expected.

Finally, in order to configure the VirtualHosts https://docs.bitnami.com/aws/infrastructure/lamp/configuration/configure-custom-application/:

  • You will need to set the ServerNames and ServerAlias parameters in the /opt/bitnami/apps/testatc/conf/httpd-vhosts.conf. You will need to do the same with the other folders.
  • Remove the httpd-prefix.conf lines from the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf
  • Include those files in the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
Include "/opt/bitnami/apps/testatc/conf/httpd-vhosts.conf"
Include "/opt/bitnami/apps/testdo/conf/httpd-vhosts.conf"
Include "/opt/bitnami/apps/yasholding/conf/httpd-vhosts.conf"
  • Generate the certificate files
sudo ln -sf /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apps/testatc/conf/certs/server.crt
sudo ln -sf /opt/bitnami/apache2/conf/server.key /opt/bitnami/apps/testatc/conf/certs/server.crt
sudo ln -sf /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apps/testdo/conf/certs/server.crt
sudo ln -sf /opt/bitnami/apache2/conf/server.key /opt/bitnami/apps/testdo/conf/certs/server.crt
sudo ln -sf /opt/bitnami/apache2/conf/server.crt /opt/bitnami/apps/yasholding/conf/certs/server.crt
sudo ln -sf /opt/bitnami/apache2/conf/server.key /opt/bitnami/apps/yasholding/conf/certs/server.crt
  • Restart Apache
sudo /opt/bitnami/ctlscript.sh restart apache

Let us know if you have any questions or if something doesn’t work as expected

Hi @jota
I go with your documentation:
https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/

and moved the demo folder and do the steps … and I can access the demo folder using IP/demo as

in the httpd-vhosts.conf file for the demo application I set the following text:

image

I then tried to type ww1.testatc.co in the browser to test it, but I got this

how can I test if the hosting is okay?? and why the url is not opened the defult page??

here is a bitnami support tool code if you want to check it:
3733eec2-2d8f-1ac4-1c43-77b542e10990