How to Connect mongodb to cpanel shared server - database

Dears,
I recently got my hands on a shared server ran by cpanel, and I want to host a mern stack app on it, is it possible to configure mongodb using it?

 Currently cPanel does not support mongodb so you should read this thread.
In order to deploy an application with these characteristics it is recommended to use Node.js since it has the necessary compatibility (mongodb driver).
Read this article (optional): How to Configure and Deploy CloudLinux’s Node.js.

Related

Is it possible to connect to google cloud postgresql from a react app hosted on Firebase Hosting?

I have run out of patience trying to figure out if connecting my react app (hosted on Firebase) to my google cloud postgresql database is possible and how I would go about it.
From what I've read, a Unix socket appears to be the only potential solution but even this approach has yet to yield any success.
Is a Unix socket the answer? Is there another way? If no, is it possible to move my react app over to be hosted on Google App Engine and connect to both Firebase and postgresql there? (the GAE documentation appears as though hosting there could work but once again the endeavor has proven to be rather complicated)
Yes, you can integrate Firebase with Google Cloud SQL:
Set up Firebase and a Google SQL instance.
Add the node SQL package to Firebase Functions
Add your Google SQL credentials as Functions environment variables.
Here you can find a detailed tutorial about MySQL but the process should be similar for PostgreSQL link.

How to connect Google Cloud Library for Datastore to the App Engine development server?

We are planning the migration of an internal app running on Google App Engine Standard Environment for Java 8 from the now superseded App Engine APIs to the recommended client library for Cloud Firestore in Datastore Mode, also in order to enable porting to other execution environments.
Besides a host of issues with missing IN/OR query operators, we are also struggling with the setup for local testing: according to Using the Java 8 Local Development Server
The development web server simulates Datastore using a local
file-backed Datastore on your computer. The Datastore is named
local_db.bin, and it is created in your application's WAR directory,
in the WEB-INF /appengine-generated/ directory.
but we have no clue about how to connect Google Cloud Client Library for Datastore to the local emulator.
Defining default credentials with
gcloud auth application-default login
or setting the GOOGLE_APPLICATION_CREDENTIALS environment variable after obtaining the credentials for the service account with something like
gcloud iam service-accounts keys create key.json \
--iam-account=project-id#appspot.gserviceaccount.com
as suggested elsewhere, just results in the client library connecting to the actual cloud server, rather than to the local emulator, as per the ADC policy.
I'd expect the development server to automatically provide connection hints to the client library, but that's apparently not the case.
Any suggestion for setting up a local testing environment, taking into account that we can't just migrate to the standalone Datastore Emulator, as we need other services currently provided only by the App Engine development server (e.g. email submission)?
Edit / After further tinkering we are working around the issue by using both the Local Development Server and the standalone Datastore Emulator as:
gcloud beta emulators datastore start \
—project=project-id \
--host-port=localhost:8081 \
--data-dir=target/war
DATASTORE_EMULATOR_HOST=localhost:8081 java_dev_appserver.sh \
--port=8080 \
target/war
However, the process is quite cumbersome and difficult to automate: what we are looking for is a way to automatically connect Google Client Library to the Datastore Emulator managed by the Java 8 Local Development Server when launching the app with something like the App Engine Maven plugin, e.g. mvn appengine:run.
This GitHub issue was closed with the confirmation that the Datastore Client Library is not compatible with the local Web Server Datastore Emulator.
I actually tried it, to see if was possible to force a connection to the local Web Server. The code below sets a custom builder with the desired host configuration:
DatastoreOptions.Builder builder = DatastoreOptions.newBuilder();
builder.setHost("http://localhost:8080");
builder.setProjectId("<PROJECT_ID>");
Datastore ds = builder.build().getService();
Key key = ds.newKeyFactory().setKind("MyEntity").newKey("mykey");
Entity entity = Entity.newBuilder(key).set("p1", "Hello World!").build();
entity = ds.put(entity);
System.out.println(entity);
entity = ds.get(key);
System.out.println(entity);
After running the local Web Server I noticed a connection was indeed possible, however the Datastore Client Library returned the following error when trying to store new entities:
[INFO] GCLOUD: com.google.cloud.datastore.DatastoreException: Non-protobuf error: <html><head><title>Error 404</title></head>|<body><h2>Error 404</h2></body>|</html>. HTTP status code was 404.
With the following output by the Web Server:
Oct 02, 2019 3:05:59 PM com.google.appengine.tools.development.jetty9.LocalResourceFileServlet doGet
WARNING: No file found for: /v1/projects/<PROJECT_ID>:commit
I believe this adds to the confirmation that the new library is just not compatible to the old emulator.
The workaround you found is probably the best solution while you work/wait on the full migration to the Datastore mode Emulator.

How to deploy website on live server?

I have created a website on angularJS. I have local server running using nodeJS. Can anyone please tell me the further process to deploy the website.
Your local server is probably only for development purposes.
You can deploy it as usual application. All you need is web server. The most common selection is Apache, nginx or IIS. You can set up one of these on your own (on your own computer/VPS etc.) or use web hosting (just google it...).
Selecting correct solution depends on budget, needed support and number of users. I assume that usual "cheap web hosting" is the best for you.

Deploy and connect build application into Bluemix PaaS?

I already deploy my application with eclipse and built in database (generated from AssestDB of the application). I want now to manage the application and deploy it with IBM bluemix PaaS, to manage Mobile Data.
What is the best DB I must use when coding before deploy into Bluemix?
If you want to configure your local test environment in order to minimize migration problems when deploying your application on Bluemix, you should replicate the target environment on your local one, as much as possible.
If you are planning to use the Mobile Data service on Bluemix please consider that it is built on Cloudant NOSQL Database, and it offers a further layer of abstraction that allows you to directly persist objects (if you are familiar with the concepts of class, object etc..).
You could also directly connect from a local application to a DB service instance running on Bluemix.

Using Piwik alongside Node.js

I'd really like to use Piwik but what I've found so far is that it needs to run on a webserver with PHP support. Node.js web apps have their own webserver so how can I integrate the two or in other words, how can I set up Piwik to access the Node.js web app?
Also, if I were to push the web app to production, does it mean that I'll have to use two runtime environments -- one for PHP and one for Node.js -- to support the web app?
how can I set up Piwik to access the Node.js web app?
I'm not sure I understand that question. In any case Piwik is a PHP application that needs a PHP webserver (will run with Apache or Nginx for example).
The Node application will be its own webserver. You cannot run Piwik in your Node webserver, or your node app in the PHP webserver.
However nothing prevents you to install on the same server a PHP webserver and your node application/webserver and put them behind (for example) Nginx. Nginx would expose the application for e.g. http://yourapp.com and expose Piwik for e.g. http://piwik.yourapp.com.
Also, if I were to push the web app to production, does it mean that I'll have to use two runtime environments -- one for PHP and one for Node.js -- to support the web app?
Yes, unless you put your Piwik elsewhere (i.e. a second server, or also see the hosting page or even Piwik Cloud).

Resources