I have a linux website where data loaded to the page correctly all the way up until I started screwing around with chmod permission changes. I was making changes, because a js script I am using wasn't working for uploading and cropping an image, and I thought maybe it was a permissions thing in the image folders.
Anyway...
After I made changes to the permissions, rows of data no longer appear, however, I do know that a connection to the database works, because there is some data that is the username appearing in another section of the page.
I changed everything back to 755 for folders and 644 for files and the data rows just do not appear anymore.
Here's the kicker, the exact same files work fine on a localhost server I'm running on a Windows 10 PC. Same exact database too.
Does anyone have any idea what I did wrong? I have confirmed that the files on my localhost server match exactly the files on the website, and the connection for both servers is going to the same MySQL db.
I am truly stumped on this one.
Thanks
This is a Linux/Apache/Nginx issue, rather than the tagged Javascript/PHP/MySQL.
Both Apache2 and Nginx run as a specific user. The current Apache2 default user is www-data, which is a member of the www-data group. If permissions are changed to disallow this user access to files, they will not be able to be served by Apache.
You should make sure all assets are readable by the user your webserver is using (or one of its groups).
It's also worth noting that permissions on MySQL databases are different to Apache2/Nginx filesystem permissions. Being able to access database data doesn't mean your server's filesystem permissions are correct.
I'd also suggest you use Chrome's inspector to check whether your assets are loading; and check your webserver logs to see what errors are popping up.
Related
I've been working on a game in javascript for my CS course. When I open the document by hitting run in Webstorm, it loads the game correctly, however when I just try opening the html file from Finder, the webpage opens but none of the png files I'm using for the sprites load. I opened Inspect Element in google chrome, and the javascript files loaded correctly but all the png files listed as canceled. This doesnt happen when the game is run from webstorm (when I run it from webstorm, all image files load properly).
When the game is opened directly from an html file (that's when I have the problem), chrome lists the path of the html document as the webaddress, although when opened from webstorm, it lists http://localhost:63342/CS%20Week%2010/CS105_Jessica.Davis_DogGame.html?_ijt=tmrr2fndgac82h07hlvt101gi4
How can I get around this issue so that when opening the html file from Finder it loads everything correctly? All image files are in the same directory as the html file.
Because of browsers security, loading files like this might not work from a url starting with file://
What webstorm is probably is making a local web server so that instead of saying file:// you could say http://. if any website was able to load images from file:// then any webpage you visit would have been able to search for any file on your computer and send it over the internet without your consent so browser often have these settings on. So you'd need a server. If you are working on your computer, you could make a local server just like webstorm and host your own files there. or host it on another service like github pages or codepen.
Now since all images are in the same directory, make sure that every time you call loadImage you use the images name and extension instead of saying /User/user/whatever_other_directory_you_have_it_under/image.png.
Once you did that you can make a local web server for the project. To make a local server, open Terminal (an application under utilities, you could spotlight search for it as well) and type cd, drag your project folder and drop it over terminal, and hit enter. Then type python -m SimpleHTTPServer and wait till it says something like Serving HTTP on 0.0.0.0 port 8000 .... Then taking the 0.0.0.0 and the 8000 you see in the example (yours may or may not be the same) go to your browser and type http://0.0.0.0:8000 (replacing the digits with whatever you got, not this link doesn't work until you do that)
Images should load alright. If you need to stop the server you can go back to terminal and hit control+C.
Note that when presenting your p5 sketch, no one else would be able to see the website on their computers if you make your local server. The local server is secluded to the device that is running it (although if their making their own local server and have your project files it should work just fine).
If you want the website hosted so that you could share a link with anybody in the world you could use codepen or github pages. If you go to codepen.io it should be self-explanatory although you'd have to upload your images to some image hosting site like tumblr or something and add the URL source of those images to codepen or you could put everything into github for even better results!
To use github pages you'd need to make a github account (preferably with your username being whatever you want your page to be named). Make a repository named insert_username_here.github.io. add your files to the repository (make sure to try to keep all sub directories and folder exactly as they are from your project folder). After a minute or two go to http://insert_username_here.github.io to admire your brand new hosted webpage!
I am Writing some php files and testing them on local server (xampp)
My problem is that when i directly open a file in browser by double clicking on it. it shows me local drive path like file:///C:/xampp/htdocs/folder/file.php i want to change or redirect url of SELECTIVE FILES to http://localhost/folder/file.php
i think i need some javascript but unable to find how?
PS: i do not want all the files to change url, but SELECTIVE files.
PHP files are supposed to be served up by the server, as such if you want to see the interpreted result of your work you need to access the file as the server outputs the file.
localhost/folder/file.php
If you are double clicking the file name and a browser is opening up, then you should configure your file editor to open up so that you can work on the php file.
Just to cover the basics you need to go to the xampp control panel and click start where Apache is. Check if your firewall is blocking the Apache process from starting (I had this error when using Comodo firewall). Then if thats ok you should do what Cups said above.
If that does not work you should open up a terminal (in Linux/OSX) or Command Prompt (in Windows) and type:
ping localhost
If that give an error you need to look into your Hosts file.
I am editing files through FTP connection. The changes are not reflecting on the browsers. I have followed instructions of using key combinations such as Ctrl and F5 keys, to clear cache but for some reason nothing is happening. So the server runs on an Ubuntu. I am using an FTP connection to edit and view the files. Do I need to do something server-side to clear or turn the development mode on? Considering I have an access to the server. I have been googling and on 10-hour coding but I could not get this one to work. It's my firs time to have an access, too, if that should help.
Try restarting the server.Also ensure that the changes that you are doing are reflecting when you reopens the file using FTP connection.
I'm looking for a solution to a strange problem I stumbled upon this afternoon.
My category pages began throwing a 404 not found error for a media/js file (one of the Magento-generated merged js files, I believe). Naturally this has caused the category pages to malfunction in a few places, including placing an unexplained number at the top of the page and breaking the nav. Here it is in action: http://www.vapetropolis.ca/herb-grinders.
I've tried disabling js and css merging in the backend. I've also tried flushing magento cache, flushing cache storage, flushing the javascript/css cache, as well as manually deleting all entries within var/cache. After all this flushing, the media/js directory is empty. However, the category pages are still looking for this same file (all other pages are still working fine).
Notably, the identical site on my local machine is working fine, and includes the file not found by the production site.
Edit: throwing the js file from the local to production site hasn't helped - there are multiple js errors thrown on the category pages still.
I'm guessing this problem has something to do with Magento's messed up merge functionality.
Edit(2): Problem has to do with caching (thank you runamok). When a querystring is added to the URL, the page works fine. So it must be that magento's caching is serving up a faulty page somehow.
I've tried disabling all cache, as well as disabling precompiling on the backend, but behaviour remains the same
Edit(3): Still in need of help!
Looks like you may have fixed the issue based on this url existing.
http://www.vapetropolis.ca/media/js/a87bf7cc5dcd7a07e58a41c1063e1f4a.js
Generally speaking this is because the permissions for the media/js file are not correct.
Obviously chmod 777 is the easiest way to set this but ideally you should just make sure the directory is owned by the user running apache.
Furthermore if you are using some sort of full page cache you will likely need to flush that too. The pages expect that the file is already there so it will not attempt to regenerate it.
Finally are you using any sort of service like cloudflare or varnish or a cdn or anything else that may cache the 404 for a short time?
Is there any client-side script that would be able to make changes to a file on the hosts computer? (Intention stated below)
I am creating a packaged app for chrome which can show some online data, and make it available even when offline.
There is a certain thing, for e.g. 'a webpage' i want to show/store (but i cannot get/read its contents due to it being on different origin). To show when online, i can use iframe, but am unable to preserve it for offline.
So i thought i could make an appcache (manifest within the application package) which will cache the file, and on press of an update button a script would run which would make some change to the manifest which would force the cached resource to be reloaded.
I searched a lot, but no results.
Any suggestions as to how it can be done. Or any other way to get it to work?
I don't think so. This could be a huge security problem if it existed.
If you had to, you could send an ajax request to the server to create a file it creates with the current prices, and add it to the appcache file.
Here is a link to another SO quesitob that has a list of APIs you could use to get your stock price.
Webservice to get stock quotes?