permission error when trying to run node server in godaddy - node.js

im trying to run a nodejs server on godaddy using the cpanel thing. i followed this tutorial, and got to the part where you run the server file. however, the server gives me a permission error.
there may be something wrong with my file structure, or the tutorial may be out of date, as my file structure differed from that in the tutorial. ex: tutorial said to go to /home/username/public_html, but my public_html folder is located on the root folder.
Update:
i just found that i could change file permissions, and enable the execute option on the node file. i'm now getting a segmentation fault error
if you need any extra information, let me know.

Related

ddev launch command returns "File not found."

My organization is establishing a ddev-pantheon setup on Windows 10. Successful "ddev pull pantheon" commands have executed. 403 errors arose after running ddev start and clicking the project links; this error disappeared after establishing the folder with "index.php" as the docroot folder in my "config.yaml" file. However, now "File not found." is being displayed after clicking both project links (those returned after a "ddev start" or "ddev restart" command). Could it be that some file in the repo linked to the index.php file is having trouble locating another file - how do I get rid of this message and view the site?
If anyone is willing to help me establish a functional connection, then I would appreciate it. It will also be helpful to know where ddev users usually clone their git repositories and how I can locate the files downloaded following a "ddev pull pantheon" command. Could the presence of lando .yml files cause issues? Any help is appreciated. Thank you.
Moving the "index.php" file (and those referenced by it) into the initial docroot folder did not get rid of the "File not found." message. Neither did deleting the repo, redownloading it, and establishing the new repo folder as the docroot folder in the "config.yaml" file resolve this issue.
As you discovered, the most common reason to get a 403 is that your docroot is set wrong (or that there is no index.php or index.html in your docroot). This happens enough that there's an FAQ for it, https://ddev.readthedocs.io/en/latest/users/basics/faq/#why-do-i-get-a-403-or-404-on-my-project-after-ddev-launch
Please look at your .ddev/config.yaml and see what's there for docroot when you're having this problem, and use ddev ssh to inspect what's inside the container.
ddev logs may help you understand why the 403 is happening.
You don't say whether you're using mutagen or not.
ddev pull pantheon should have nothing to do with your 403 problem; it's not clear why you mention ddev pull pantheon. I supposed you could have a really messed up pantheon.yaml that could do it, or that you could be downloading a broken database. Are you saying that your project is only broken after you do a pull? If so, ddev delete -Oy will get you back to where you started, so you can demonstrate that. You can also do ddev pull pantheon --skip-files or ddev pull pantheon --skip-db as part of your debugging process.
The way things should be working:
You should have checked out your git repo that has the code for your project.
On most project types you would have done a ddev composer install after that.
Then a ddev pull pantheon would load your database with the upstream database. You can see the contents of the database with ddev mysql or by using the PhpMyAdmin UI (ddev launch -p).
The files from Pantheon will be put into your upload_dir. For example, this would be web/sites/default/files on a standard Drupal project.
BTW, the recommended environment on Windows is WSL2, you'll like it a lot in the long run.
This sort of problem would be easier to sort out in a more interactive environment, so you're invited to the DDEV Discord at https://discord.gg/hCZFfAMc5k .

NodeJS cPanel Hosting

I set up a NodeJS API on cPanel using the NodeJS setup that is provided. the app starts but none of my endpoints are reachable with 404 pages being displayed.
In the cPanel > metrics > errors I can see the error: Path for NodeJS application is invalid: /home/username/repositories/repo
where username is the cpanel username and repo is the server.
I used the built in git support in cPanel to link to a remote repo via SSH. This part is most likely not the problem since I can see the actual server files referenced in the NodeJS server with the correct path (which is why this error message is so strange.)
The server works fine on localhost so this likely has something to do with cPanel.
I have never hosted a node app on cPanel and I know a VPS would be better but this is what I have to work with for now. There isn't a lot of discussions/forums/docs on this online so I am running out of options.
I would highly appreciate it if someone can tell me what is wrong or guide me in the right direction for where to start looking for the problem.
I solved the problem. When you don't use a git repo you can use a relative path from your home to the place the server is stored. i.e. don't include home/username/ in the path
for git repos you must use the absolute path meaning
home/username/repositories/yourserver
where "username" is your cPanel username and "yourserver" is the name of the folder where your server is located

Why do all my browsers show error that the phpmyadmin config.js file is forbidden?

Ubuntu 20.04
Apache 2.4.41
phpmyadmin 4.9.5deb2
I can log in to phpmyadmin and see the main page where the databases are listed in the left-hand panel. But I get an error message. Using F12, I see the following error:
Failed to load resource: the server responded with a status of 403 (Forbidden) config.js:1
There is a config.js file under /usr/share/phpmyadmin/js. There are other js files in that folder that are included in the sources listed in the browser (again, using F12).
I confirmed that the config.js file has read permissions set for everyone. All the js files in that folder have the same permissions set.
I also confirmed that /etc/apache2/conf_enabled/phpmyadmin.conf links to /etc/apache2/conf_available/phpmyadmin.conf and that links to /etc/phpmyadmin/apache.conf. Neither this apache.conf nor /etc/apache2/apache2.conf deny access to config.js.
When I delete config.js, I do not get the error BUT I get other errors concerning functions that are contained in that config.js (like "Uncaught ReferenceError: isStorageSupported is not defined."). This tells me that the forbidden file is indeed this file. I renamed it and created a new empty config.js - still get the same forbidden error(fwiw).
We've been using phpmyadmin on this server since April. The error has cropped up in the last couple weeks. When I ssh'd into the server this week, it displayed a message that it needed restarted to make updates. I did not know there were auto-updates going on. I restarted, which did not help the problem. Then I updated and upgraded everything but still no help. I uninstalled (remove and purge) and installed phpmyadmin, but still no help.
My next step would be to upgrade phpmyadmin to the latest stable using a different repository (the debian repo is a little behind). But I thought I'd ask here because I have a feeling that might not help either.
I'm thinking that something changed in the server stack that isn't allowing the config.js file to be read; I just have no idea what that would be. Has anyone else seen this or something similar?
I implemented a band-aid: I copied the /usr/share/phpmyadmin/js/config.js file to config.1.js. I edited the code in /usr/share/phpmyadmin/libraries/classes/Header.php to use config.1.js instead of config.js.
No error now!
But I don't like this answer because it doesn't tell me what the original source of the problem is and how to keep it from happening again.

apache2 on ubuntu webserver rejects permission to access any other file than the delivered index.html

I am trying to set up a webserver running on Ubuntu. I have installed Apache and changed the root directory to an other directory within /var/www/. When I copy the index.html provided by Apache to that directory, I can access that file via remote webbrowser. But if I want to use a different index.html file, even really basic ones, I get an error: "Forbidden You don't have permission to access this resource". I have also tried to download that html, alter just a few lines and put it back on to the server with the result that it also shows that error. If I rename the initially provided index.html to index2.html I can still access it. I do not understand how it is possible that only this exact file is working.
I have tried to grant more permissions with Directory and restarted Apache but it won't work. I am rather new to Linux and Apache, can only use the terminal on my webserver and I do not know what else to do. Please help.
Change the permissions on the file, too, not just the folder. Pretty sure this fix it.
For diagnostic correction, allow permission for all by typing:
sudo chmod -R 777 /path/to/index.html

Error: ENOENT, no such file or directory './assets'

After setting up koa-static-folder, my image loads great when I test over localhost with http://localhost:3000/assets/myimage.jpg
But after deploying our node code to an Ubuntu server, we get:
Error: ENOENT, no such file or directory './assets'
What's Ubuntu's issue here? Not sure how to resolve this.
The code that is working locally is:
var koa = require('koa')(),
serve = require('koa-static-folder');
koa.use(serve('./assets'));
Sounds like a permission issue (but I could be wrong!) such that the user that node.js is running under does not have access rights to the assets folder. If this is the problem you have to change access permissions to the folder (see chmod) or run node.js as a user that has the access rights.
If the server isn't publicly accessible you could run the application as sudo to verify if it is a permissions problem or not. Note that using sudo is not a long term solution since it is highly irresponsible/unsecure to run the application as the root user.

Resources