Help setting up apache2 virtual host config for bitnami wordpress for two sites (Not multisite)

Keywords: WordPress - AWS - Technical issue - Other
bnsupport ID: 22f8185e-6bba-9454-b54d-e5e5541298c8
Description:
I have two wordpress sites running. The first site I setup using bitnami and it works fine in /opt/bitnami/apps/wordpress/htdocs. The second I created a subdirectory in /opt/bitnami/apps/wordpress/htdocs/secondsite and setup wordpress within that subdirectory. They both use the same database where I modified the wp-config.php file and chose a different table prefix, etc. and that works fine. But I am not able to figure out how to modify the virtual host config for apache2 to point to http:mydomain.com = /opt/bitnami/apps/wordpress/htdocs and http:mydomain2 = /opt/bitnami/apps/wordpress/htdocs/secondsite

I tried following the document here https://docs.bitnami.com/general/infrastructure/lamp/configuration/configure-custom-application/ but there isn’t enough information in it to properly setup a site. Do I need to modify my .htaccess file or htaccess.conf as well, or other permissions?

Hi @Ron2,

Thanks for using Bitnami. I think it is easier (and safer too) if you install a fresh new Bitnami WordPress module on your current Bitnami installation as mentioned in this guide

https://docs.bitnami.com/installer/apps/wordpress/configuration/install-several-wordpress-modules/

You will need to download the Bitnami WordPress module from our website to your server and then run it as shown below. Remember to substitute the VERSION and NEW_BLOG_NAME placeholders for your values.

sudo chmod a+x bitnami-wordpress-VERSION-module-linux-x64-installer.run
sudo ./bitnami-wordpress-VERSION-module-linux-x64-installer.run --wordpress_instance_name NEW_BLOG_NAME

Installing a new WordPress site this way will ensure that they are independent (and will use different databases as well).


If you want to keep using your current configuration, you need to follow the next steps:

  • Modify the current virtualhost configuration setting the ServerName and ServerAlias for your main site: mydomain.com in the /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf file.
  • Copy and paste that configuration at the end of the file and modify the ServerName, ServerAlias and DocumentRoot with the second website values.

At the end of those steps, the /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf file should looke similar to this (but with your actual values instead of the placeholders)

<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"

    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

<VirtualHost *:443>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    SSLEngine on
    SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"

    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

<VirtualHost *:80>
    ServerName othersite.com
    ServerAlias www.othersite.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs/secondsite"

    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

<VirtualHost *:443>
    ServerName othersite.com
    ServerAlias othersite.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs/secondsite"
    SSLEngine on
    SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"

    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>
  • Include this file in the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf by adding the line below
Include "/opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf"
  • Restart Apache for changes to take effect
sudo /opt/bitnami/ctlscript.sh restart apache

Best regards,
Gonzalo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hi Gonzalo, thanks for the information. If I install a fresh new worpress module will it still use the same MySQL installation or will it install another MySQL instance ? Wordpress is running on a low-powered machine so two instances may use a lot of resources. Also will I need to adjust the virtual host files for both bitnami installations in this case as well because there will be two sites on the same machine? Thanks!

Hello, After running through the installation the secondsite directory is put at /opt/bitnami/apps/secondsite.
So the DocumentRoot is “/opt/bitnami/apps/secondsite/htdocs”

Do I need to modify the .htaccess file at "/opt/bitnami/apps/secondsite/htdocs/.htaccess ? Currently it is a copy of the firstsites .htaccess file. I receive this error when trying to access the secondsite.
AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: http://secondsite.com/mydir/wp-admin/install.php

Hi @Ron2,

yes, the Bitnami module only installs WordPress and uses the existing servers in the instance.

Our applications don’t use the .htaccess file by default due to security and performance reasons

https://docs.bitnami.com/aws/apps/wordpress/administration/use-htaccess/

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. 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 Gonzalo, thanks for your guide!
I still have two doubts

  1. in this configuration the two websites share the same .htaccess (better said the same httpd-app.conf)
    May I duplicate it if I need any customization foe the single website?
  2. any customization of the classic .htaccess are totally unuseful because with bitnami configuration apache bypass its condition?

Thanks in advance

CS

Last but not the least, I followed this guide for having SSL certificate
https://brandviser.com.au/how-to-install-ssl-on-wordpress-lightsail/

and it worked perfectly for the first domain,
Now for the second virtual host (the one inside the subfolder)
I receive in ssllabs.com a mismatch error for the Certificate #2: RSA 2048 bits (SHA256withRSA) No SNI,
reporting the name of the first website.
Is there any part of apache/bitnami configuration that I need still to modify?

Hi @zensabbah,

Thanks for using Bitnami. Please find my comments inline

  1. in this configuration the two websites share the same .htaccess (better said the same httpd-app.conf)
    May I duplicate it if I need any customization foe the single website?

Yes, you should duplicate it so you can easily customize each site.

  1. any customization of the classic .htaccess are totally unuseful because with bitnami configuration apache bypass its condition?

.htaccess files are disabled for performance and security reasons. You can use the /opt/bitnami/apps/WORDPRESS_SITE/conf/htaccess.conf file to add the content of the .htaccess files. You can get more information on this in the link below

https://docs.bitnami.com/aws/apps/wordpress/administration/use-htaccess/

Now for the second virtual host (the one inside the subfolder)

Regarding SSL certificates, please note that we do not support certbot. We support the lego client. We also have a tool that allows you to automatically create and configure an SSL certificate for your domains. You will only need to provide the tool with all the domains you want to generate the certificate for

https://docs.bitnami.com/aws/how-to/understand-bncert/

Apart from that, I will close this thread as too old. Please open a new thread in our forums if you have any further questions.

Regards,
Gonzalo