PHP file not working on hosting - php

So this is what's happening. I don't know how to explain this.
I made a software which uploads file to my website's FTP location. It's working as it should.
As you can see in the folder that inside public_html/phphostrot.rviews.xyz/user_rot/ there are 2 php files. But when i visit the url http://phphostrot.rviews.xyz/ i get a blank page with inder of / and nothing else. And if i try to access http://phphostrot.rviews.xyz/user_rot/ I get 404 error. Even the link to the file is not working. I don't know what's the problem.

I think it's a issue with the file permissions. Have you configured your server to serve files from your public directory.
Try changing the ownership of the files to www or apache

app, img, wp-admin, wp-content, wp-includes?
check file permissions (+x), as #atefth said, check owner.
check webserver config. and check apache/nginx logs

Related

Azure App Services File Access

I've got a few files on wwwroot/uploads which need to be publicly accessible by anyone.
It currently throws a 404 Error, but the file exists, and the URL I'm using is correct. Can anyone guide me to configuring the access controls to this folder?
I've tried using .htaccess files (allow all), and also tried messing with the web.config file. No luck though. (The access attributes need to be applied recursively to all children of the 'uploads' directory.
Thanks all!
Update:
The problem was IIS was not configured to support the .mp4 MIME type I was trying to use. Just added that in there in the main web.config file and it works now :)
Thanks to #misaim for his help :)
This could be due to the MIME type not being enabled for media files by default. Try removing the web.config and enabling mp4 or image file and see if your errors go away.
https://en.wikipedia.org/wiki/Media_type
Have you tried changing the Systems permissions of the files? Not just the web server permissions? i.e. chmod -R 777 (Don't actually do this, use correct permissions, this is to open).

Server unable to read htaccess file

Hosted a new website. But when ever I open my website in the browser it is throwing the below error. Tried changing the .htaccess ReWriteRule but could not resolve it.
You don't have permission to access / on this server. Server unable to
read htaccess file, denying access to be safe Additionally, a 403
Forbidden error was encountered while trying to use an ErrorDocument
to handle the request.
This most likely means that apache doesn't have permission to read the directory where your .htaccess is located. Check the permissions on the folder where the file is located.
Ok, so I was facing this issue as well. Now keep in mind, the location of my application was a folder being shared with the Guest OS. Now what I had forgotten to do is to check, and make sure all permissions were enabled on said file on the HostOS.
So what I recommend is that you check the file permissions on the HostOS. Might be nothing you did, just something you forgot to do. Here is a screen shot of what I'm talking about.
Correct file permissions on left, zend skeleton displaying on right
I was unable to restart apache using my ID. So I restarted it using root user and hence this error. Later I changed access permission of httpd folder to 755 and restarted using my ID. The issue was resolved.
hello I think you have some problem with permission like it's was mentioned on your hosting you will find some number near your file like 755 those are the privilege of your file if there wasn't on that number 7 maybe 5 or 4 change it to 7 and like that your application could get the access and lunch your application

Allowing upload and browse but disallowing download

I think this question should be something easy but after searching all over the web I couldnt find an answer, so I decided to ask here.
I have a file uploader in my website that works with php. The folder where files are being uploaded has 777 chmod. I also have a php script to list the files in that folder. What I need is to allow php to upload and browse files on that folder, but dont allow people to do it. The only solution I imagined is to chown that folder to another user different than default, so I could later chmod in filezilla and allow only owner to do it, so people will see the files trough the output of the php script, but not if they navigate to that folder.
Im using Debian, apache2. Id like to know what could I do.
To make it shor, my aim: allow php to upload, read, write and execute files in that folder, but not clients unless they use my php script.
Thanks in advance
Put all the files you're talking about in their own directory. Add a .htaccess file to that directory. The contents of the .htaccess should be deny from all.
This will prevent any user from manually accessing the files as access will be blocked off. Your PHP script can still browse the contents of the file and serve it up as an attachment with the correct content type.
For more info on how to serve a file for download in PHP, read this: https://serverfault.com/questions/316814/php-serve-a-file-for-download-without-providing-the-direct-link
All services including web servers run in a security context which is an account in the OS, for example apache starts using apache user in apache group. It is enough to change mode and change owner to this user and group. Never chmod a directory to 777 until there is a good explanation for that. Using this trick, web service process only can read, write and execute in that directory.
As well, if you want the browser clients not to see(read) the contents of that directory, you should deny listing on that directory. I think it is disabled for default.

How to change uploaded file permissions for new files automatically

I recently moved a wordpress site from media temple's gs to their dedicated virtual server.
The file structure changed when I upload files. The permissions automatically upload as 644 and I'd like to change this. Where should I look to change this, the php.ini file or somewhere ont he server settings? It uses plesk.
You're going to want to find a way to change your umask. You might have to talk to your server administrator about it, if you don't have shell access.

401 error on iis when uploading files via PHP

I have an upload script that runs on a windows webserver 2008. The uploads works nice, the file is created on the server. But when I try to access the uploaded image file via http, I just get an error 401. How can I resolve this?
EDIT: setting the chmod to 0777 after the file has been uploaded did not help, too.
That did it: https://serverfault.com/questions/85983/iis-iusrs-cannot-access-files-uploaded-and-created-by-network-service-error-401/229151#229151
For security reasons, many websites sequester uploaded files until they are validated, at which time they are made publicly accessible. If this is the cause, you'd have to ask the site's administration.
So to summarize : one of the solutions is :
Edit "upload_tmp_dir" inside of php.ini and for example set to "C:\my_temp_folder"
Than right click to folder and security tab than give modify permission to the IUSRS user ;)

Categories