Search code examples
google-compute-enginebitnami

How to create opt/bitnami/apps/myapp/conf/httpd-prefix.conf and include /opt/bitnami/apps/myapp/conf/httpd-app.conf


Please guys help out, am using google compute engine for the first time and using bitnami. I have successfully spin up a server, and connected with ssh but am stock here https://docs.bitnami.com/virtual-machine/components/nodejs/#how-to-create-a-custom-nodejs-application Can anyone help me explain how:

1.- Create and edit the /opt/bitnami/apps/myapp/conf/httpd-prefix.conf file and add the line below to it:

Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"

2.- Create and edit the /opt/bitnami/apps/myapp/conf/httpd-app.conf file and add the content below to it. This is the main configuration file for your application, so modify it further depending on your application's requirements.

ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/

NOTE: 3000 is the default port for the Express server. If you have customized your application to use a different port, change it here as well.

3.- Once you have created the files and directories above, add the following line to the end of the main Apache configuration file at /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf, as shown below:

Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf" 

Solution

  • According to the Bitnami guide shared by you, you should follow the following steps (I added more detailed information):

    1.- Create directories

    For that, you should run the following commands:

    sudo mkdir -p /opt/bitnami/apps/myapp
    sudo mkdir /opt/bitnami/apps/myapp/conf
    sudo mkdir /opt/bitnami/apps/myapp/htdocs
    

    2.- Create two files

    For that, you can run the following commands:

    touch /opt/bitnami/apps/myapp/conf/httpd-prefix.conf
    touch /opt/bitnami/apps/myapp/conf/httpd-app.conf 
    

    3.- Add content to the first file

    You can edit the file using any text editor, for example nano

    nano /opt/bitnami/apps/myapp/conf/httpd-prefix.conf
    

    The above command opens the text editor, you should copy/paste or write the following line:

    Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
    

    Close the editor using Ctrl+X(you will be prompted to save your file if you have not)

    4.- Add content to the second file

    You can edit the file using any text editor, for example nano

    nano /opt/bitnami/apps/myapp/conf/httpd-app.conf
    

    The above command opens the text editor, you should copy/paste or write the following line:

    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/
    

    Close the editor using Ctrl+X(you will be prompted to save your file if you have not)

    5.- Edit Apache config file

    Once you have created the files and directories above, add the following line to the end of the main Apache configuration file. Open the file (again using nano):

    nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf
    

    The above command opens the text editor, you should copy/paste or write the following line:

    Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf"
    

    Close the editor using Ctrl+X(you will be prompted to save your file if you have not)

    6.- Restart apache

    For that execute

    sudo /opt/bitnami/ctlscript.sh restart apache
    

    7.- Start the Express server

    cd /opt/bitnami/apps/myapp/htdocs
    ./bin/www
    

    Alternatively, use the following command to start the server and keep it running even after your server session ends. Replace FILE with the correct filename for your application.

    forever start FILE.js