when I 7zip a folder with php files on a PC and send it to my Mac, I can extract everything properly etc. But as soon as I turn on the localhost and want to open them in my browser, I get
"You don't have permission to access the requested object"
Even if I change permissions to read, write and execute for everyone, I cannot access the files in my browser.
What do I need to do?
Thanks
Dennis
Maybe in your Apache HTTPD config file/.htaccess there is a restriction.
Also, look the chmod of your file, even if the directory is chmod'ed 777.
Try testing on a new hello world php script in your project directory, you will see if you can execute it.
Make sure that the apache can read the files. For testing porpose you could run chmod 644 filename and also chmod 755 dirname.
If you played with the server configuration make sure that the server configuration allows the clients access to that path.
Related
I've just uploaded a simple symfony2 app on a production server, and I get this configuration error:
2 MAJOR PROBLEMS
Change the permissions of the "app/cache/" directory so that the web server can write into it.
Change the permissions of the "app/logs/" directory so that the web server can write into it.
editing "app/console", "web/app.php" and "web/app_dev.php" with: umask(0000) doesn't work, and if I right click on that folders with FileZIlla, their permissions are already 777. And so?
thanks...
You need to recursively set the permissions, most likely. I'm guessing FileZilla has that option, if not, ssh into the box, and run (replacing /path/to with the actual path)
sudo chmod 777 -R /path/to/app/cache
sudo chmod 777 -R /path/to/app/logs
Sidenote: setting the permissions to 777 is usually a really bad idea.
umask(0000) doesn't actually increase the permissions available to the script. It just ensures that files & directories created by those scripts are accessible from both the command line and the web server. If you're not using the command line, you probably don't need it at all.
I am using a PHP application to generate links to files. Links are basically PHP files (abcd.php) with permission 644 put into a directory public with permission 755.
When I try to access public/abcd.php via browser I get a 500 Internal Server Error. If I change the file permission to 755, the system works.
I am using a cheap web server so I do not have much access to logs. What can be the cause of the problem? Can I solve the issue?
Thanks
644 on any server side script is likely to have problems because no executable flag is set
644 means that the owner can read and write and the rest of the world can read
755 means that the owner can do everything and the rest of the world can read and execute.
By rest of the world I really mean, other users on the server (eg. Apache which is likely to be the web server that your hosting runs upon)
Maybe PHP run as CGI on your server, and not as an Apache DSO module, so it needs the execution bit.
Try a phpinfo() to see if PHP run as CGI...
I´am with a problem for search a file on a linux server, i try to read a directory but i can´t set permission for the script on php read that directory.
The problem is not the permission by himself, because i set chmod -R 777 [file] and this don´t work, for make the problem worse that directory is a link to another directory so i don´t know if the problem is the origin or the destination.
PHP and Apache must be in a group that has access to that directory.
I just setup a LAMP development server and am still trouble-shooting some things. The server is installed on one computer and I use a Windows laptop to write my code and test the site via the web browser.
My file uploading script works in that JPEG image files are successfully uploaded to the server, but when I try to view the images in the web browser, permission is denied.
I check the permissions on the file via the server and they are 600. I can fix the issue by chmod 777 theimage.jpg, but this doesn't seem like a good solution at all.
Does the solution have something to do with Apache configuration? Or is there something else I should be doing.
Thank-you,
Mike
Update
To clarify, I am able to upload a JPEG file to /var/www/test/images, but am unable to view the image in the web browser after it has been uploaded. My script works on the production server (I am using Dreamhost). This leads me to believe that the issue is with the development server that I have just setup. Any feedback is greatly appreciated, even if it is just resources that I should read for better understanding the server setup.
You need to change the permissions on the folder containing the file, not just the file itself. Use sudo chmod and sudo chown on the directory that contains the file you want to access, then check to make sure the permissions where changed with the ls -rl command. The permissions used with chmod should be r and w and the directory should read -rw-r--r-- when the ls -rl command is used if the permissions have been changed correctly. Also, if you are still unclear about the specifics of how chmod and chown work check out this link and this link.
EDIT:
Type this:
sudo chmod -R 666 /var/www/test/images
Or this:
sudo chmod a=rw /var/www/test/images
... to do what you want to do. For more explanation see my latest comment entry below.
I'd say you probably are running PHP under a different uid than Apache.
You can:
Configure apache/PHP so that they run under the same uid
Upon file upload, use PHP tochange the permissions with the chmod function or change the umask associated with the PHP process so that the file gets the correct permissions in the first place
Access the images through PHP (readfile) -- not recommended for performance issues
How should I handle image uploading using PHP?
How should I handle the chmod settings?
Example;
I have a dir called /image/ where i want to upload all my images.
Should I set this dir to chmod 777 and leave it like that? Or should i change chmod on that folder via PHP each time I need to upload a image. Is this correct, or should I be doing something else?
As thephpdeveloper mentioned, setting chmod once is enough. All subsequent writes into that directory will not change the directory permissions unless you explicitly chmod it to another permissions somewhere else.
The recommended permissions for directories on a *nix server is 755.
Setting permissions to 777 is not recommended. As mentioned by wic, it gives full permissions to everyone that have access to your server. Which makes it vulnerable if you are on shared hosting or sharing the server with other users.
Also to note is how PHP is run on your server. In fact, if you are running PHP as cgi, example suphp, permissions of 777 for directories are not allowed. Having 777 permissions on the directories your scripts reside in will not run and will instead cause a "500 internal server error" when attempting to execute them.
I recomend chmoding to 755
Only the user running the web server dameon needs permissions to the directory for writing. And you certainly don't want execute permissions on a directory users are uploading to.
Usually, folder settings are set once and that's it. It's rather pointless to keep setting the folder permissions to 777 via PHP, when you have already set it to 777.
No, you dont have to change the permissions on the directory each time. Once set, they are set so to speak.
Using 777 is overkill since it gives full permissions to everyone. Remove the 'x' bit and let apache (or whoever) own the directory. This makes it impossible to list files.