Mac Lion Apache can't view files in document root - macos

Apache is running, localhost is working, if I put an index.html that works as well. However I can't access any folders (my websites) within the document root, which is /Users/Me/Sites
I get a forbidden error when I try to access these.
What's going wrong?

You should check the permissions of your home folder and your sites directory to make sure that they allow Apache access.
You could check the permissions, or just run (in a Terminal)
chmod o+x $HOME
chmod -R o+rX $HOME/Sites

Related

How to solve the problem of accessing the storage in Laravel folder

Faced a problem accessing the storage folder. A symbolic link was created, but when I try to access any file in the storage folder, I get an error 403 "You do not have permission to access this object. The file is not readable, or the server cannot read it." I have a second project on a local machine, everything works fine there. I tried to give 777 permissions to the storage folder, but this causes the "Permisson denied" error. I will be glad to any help!
Macos catalina
Laravel Permissions
first change ownership of the laravel directory to our web group.
sudo chown -R :www-data /var/www/laravel
Next we need to give the web group write privileges over our storage directory so it can write to this folder.
sudo chmod -R 775 /var/www/laravel/storage
where laravel is the name of the root

NGINX gaves 404 error after creating a symlink

My site runs on php-larvel and nginx as webserver and the root diectory is /public , everything was ok ,but when I wanted to secure my phpmyadmin login url , creating a symlink by this command in /public_html :
ln -s /usr/share/phpmyadmin/phpmyadmin-YOUR-SECRET-CODE
site went down showing 404 , and the nginx shows this error:
2019/04/07 07:09:02 [error] 4163#4163: *110 directory index of
"/home/admin/web/example.com/public_html/" is forbidden
the nginx configuration has already set to serve on /public . I don't know why it is trying to access public_html on requests .
The user that NGINX is running as must be able to access the directories its attempting to read and/or write to. In most cases, NGINX is either running as the user nginx or www-data.
We can check for the user directive in /etc/nginx/nginx.conf by running:
grep user /etc/nginx/nginx.conf
If the return of that command spits out a user, we can then change the ownership of the directories you've mentioned using chown.
chown -R user:group /insert/path/here
So if NGINX is running as www-data:
chown -R www-data:www-data /insert/path/here
If the grep command doesn't spit out a user, we can always see who owns NGINX's directories and we should be able to use that user.
Simply run:
ls -al /etc/nginx
and grab the user from the output.
As a side note, things are a bit different if you happen to be running PHP-FPM with NGINX. In that case, the directories and files should be owned by the user that the PHP-FPM process is running as.
If you are running PHP-FPM, you can cd in to the main directory and check the pool file. If you've not modified anything there for your setup, the default user for PHP-FPM is always www-data, so that should be the user who owns all files and directories.
cd /etc/php/*/fpm/pool.d/
and then:
nano www.conf

Can't see images in localhost

I'm starting to develop a site in ubuntu 14.04. I'm using apache2, so I placed my files under /var/www/html/ folder. Everything was working fine, but I had to restart my current work so I copied the entire project folder from another path, like this
$ sudo cp ~/path/to/folder /var/www/html/
And now I can't see my images, a simple imgtag. I just see this.
When I look for the file, I can see that I'm having an error 403 forbidden. I saw some suggestion to add the option Require all granted but that option is already set in my apache. I suspect that is because the new folder is a copy from a folder without root permissions, so I tried chmod but that also didn't work so I'm completly lost now.
So, how can I see my images from localhost? and most important is why this happen suddenly?

public_html folder invisible

I have a website which I copied to this location. The public_html folder was also uploaded with the other folders but it is not showing up. Please guide me. Thanks.
As you are using DreamHost web hosting you wont have any control over ssh and chmod , chown commands. I think dreamhost wont use cPanel for shared hosting, they have their own control panel, so there is nothing you can do, Ask dreamHost support to reinitialize your public_html directory. Surely they will do that. I searched on dreamhost forum and found these link-
https://discussion.dreamhost.com/thread-13646-post-13647.html#pid13647
https://discussion.dreamhost.com/thread-128630.html
Currently in your case i saw that there is no issue related to public_html (technically "Document Root" ) directory coz as your http://www.inspuratesystems.com/second/ is pointing to correct directory , and your documentRoot is parent of that directory, So if your documentRoot was wrong then there were no chance to access that that url, currently your domain is opening a correct index.html file which indicates that your documentRoot is there.
Create a index.html or home.html file there manually (from their web based file manager) and see if it is working or not, if it works then there is some issue with your uploading.
Your hosting provider seems to be dreamhost.com
Please check out this thread, according to which public_html seems to be a special case on dreamhost:
https://discussion.dreamhost.com/thread-144453.html
and/or this:
Getting a 'Not Found' error on my website?
Hope it helps!
Make sure that the public_html folder has execute permissions
chmod a+x public_html
That will allow execute permissions for everybody.
Perhaps it's possible that server (apache?) hides folders named public_html? Also check that group others have read and execute permissions for that folder.
In folder /path/to/second/ run
chmod ugo+rx .
chmod -R ugo+rx public_html
to set folder visible.
cpanel may handle the "public_html" folder in a unique way. Try uploading to a folder like: /home/yourusername/public_html/second/files/ instead of /home/yourusername/public_html/second/public_html/
If you are wanting to create a new distinct website at inspuratesystems.com/second/ you don't need a second "public_html" folder. Just put them in the /home/yourusername/public_html/second directory.
If you are using a linux or OS X server, you may need to change the permissions on the folder.
Did you checked if the folder is hidden attribute?
If you execute ls -a in terminal, you will know about it's existence. If it is present then please try giving it read & execute permission (using chmod 555 command). Give write permission if you are planning to write something or take feedback from users (using chmod 777).
I tried some of this options above but unfortunately none worked. Instead I discovered that in CPanel you have a "Preferences" tab and in that tab you have a "User Manager" function. You can there edit the ftp user that you created before in CPanel. On the "User Manager" funcion you can find the "Home Directory" configuration. On that home directory you just choose the "public_html". When you configure the user in the ftp account on your ftp platform, it goes directly to the path you defined in CPanel.

I am unable to access my Webserver directory

I am trying to setup my Apache local server. I noticed that my access was denied after I typed localhost into both Safari and Chrome. In Chrome it works but in Safari I given error 403 and told "Forbidden" and "you do not have permission to access / on this server"
So I have tried to modify the permissions of my Webserver directory using chmod in terminal. But even there I am told that the operation is not permitted. Even when attempting ls to view its contents, I am met with "Permission Denied"
I've run into this issue from a couple of different angles on OS X. It seems as if you are having a permissions error.
I suggest you check out this post, what you need to do is make sure the _www group has access.But, BEFORE YOU DO WHAT THE ABOVE LINK SAYS, try a solution with Finder.
Go to the root web directory in your finder.
Right-click and 'Get Info'.
Look at the permission of the _www user. Make sure it has 'Read & Write' access.
Click the settings-cog on while _www is selected.
Select the following options: "Make _www the owner" and "Apply to enclosed items..."
Try accessing your web server now.
If this does not work, or if there is no _www user, revert back to the post I spoke of earlier.
Try the suggested lines in terminal:
Let DIR be the different directories leading to your website. Replace "~" with the full directory path.
For each parent directory leading to your web root (e.g. ~/my, ~/my/web, ~/my/web/root)
chmod go-rwx DIR (nobody other than owner can access content)
chmod go+x DIR (to allow "users" including _www to "enter" the dir)
Then apply these commands to just the web root.
sudo chgrp -R _www ~/my/web/root (all web content is now group _www)
chmod -R go-rwx ~/my/web/root (nobody other than owner can access web content)*
chmod -R g+rx ~/my/web/root (all web content is now readable/executable/enterable by _www)
Try to access your website again. If this doesn't work, go back to finder and try to add add the permissions again as stated in the first part of this post.
If you are using Server for OS X you may also enable and edit sharing properties for other users and FTP.
I have solved my problem with a simple fix:
Open "Disk Utilities" from the "Utilities" folder in "Applications"
Click on the root drive
Click "repair permissions"
Done

Resources