httpd not reading the document root in conf/httpd.conf as expected - linux

I have a Laravel project on my CentOS7 server which sits on the folder "/var/www/html/myProject".
I have changed my document root in /etc/httpd/conf/httpd.conf to "/var/www/html/myProject/public" both in "DocumentRoot" and in the directory configure so when i enter the IP in the browser it will automatically show the project.
When i try to do so and access my IP through the browser i am greeted with the messages:
Forbidden
You don't have permission to access /form on this server.
Server unable to read htaccess file, denying access to be safe
After further examination i have found out that in my /var/log/httpd/error_log i get the following error after every access attempt:
[Thu May 10 19:39:33.683522 2018] [core:crit] [pid 1994] (13)Permission denied: [client 79.182.62.1:51091] AH00529: /var/www/html/myProject/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable and that '/var/www/html/myProject/' is executable
That was very odd to me since the path is supposed to be /var/www/html/myProject/public, but the "public" is missing.
I have restarted my apache several times, and changed the DocumentRoot path to a fictional path just to check if it updates and it is.
Could it maybe be something in the .htaccess file? although i didn't change the file, i left it as Laravel created it.

Check the permissions on /var/www/html/myProject files & directories. Based on the error you pasted it seems apache is attempting to read in data from your myProject directory as directed by the .htaccess file. This is normal operation.
Figure out what user/group your apache is running is. Then remember that your files have to be readable that user and all parent directories have to be accessible (hint: execute bit) for that user.
Finally check the bootstrap/cache and storage laravel directories (& subdirectories) are writeable by the apache user.

Related

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

Is it possible to allow a user to access a dir without making him the owner?

For my desktop machine, I'd like to be able to access files in my home directory in a browser.
I have set the Apache DocumentRoot to my home, but I get logically a forbidden page. I tried to add www-data user in my group, with the same result.
I would not prefer give full access to any user in my home.
So how should I proceed to let apache read my home dir?
$ ls -la /home | grep gael
drwxr-xr-x 44 gael gael 4096 mars 17 22:30 gael
$ groups www-data;
www-data : www-data gael
The error log:
[Tue Mar 17 22:43:06.592819 2015] [authz_core:error][pid 4572] [client 127.0.0.1:59677]
AH01630: client denied by server configuration: /home/gael/
apache conf:
<VirtualHost *:80>
DocumentRoot /home/gael/
</VirtualHost>
make sure that the user running the webserver has full read permissions to all files they need to see. they will also require execute permissions for any directory they need to traverse into.
so it seems that you have added the www-data user to your own group, which should fulfill the above.
be aware, that a new group-membership does not take effect immediately: interactive users need to login again, a daemon needs to be restarted (thus: restart apache). the w32 way (just reboot) will also work.
btw, exposing your home via a webserver seems like a bad idea: anybody who can access the webserver (usually anybody on the same net) will be able to see your home-directory. make sure that you add extra security (password protection, encryption,...).
btw, did you know that the ~/public_html directory is traditionally exported by your web-browser as ~<user> (so if your login name is "gael" you can access this directory via http://localhost/~gael/). if the directory does not exist, just create it and make sure that you set its group to www-data. this is a much more secure way to share some data via the web.

403 Forbidden trying to access folder on browser

I have a folder in ~/Documents/WebD/ named Tarea which have a public_html folder inside, to access it I have tried creating a virtual host in a thousand ways but it didn't work, now I'm trying to get there creating a Symlink from tarea to /var/www/html/tarea, and accessing via localhost/tarea/public_html but y get
Forbidden
You don't have permission to access /tarea on this server.
Apache/2.2.15 (CentOS) Server at localhost Port 80
I tried a lot of different ways named on forums, changing httpd.conf, give permissions to apache, etc, but non of them worked
Any suggestion?
It could be SELinux preventing Apache from accessing those files. I would try switching SELinux into permissive mode and seeing if your permissions open up. You can read more about SELinux and Apache here.
To put SELinux into permissive mode, do:
echo 0 > /selinux/enforce
To put SELinux back into enforcing mode, do:
echo 1 > /selinux/enforce
Hope you have already checked Persmissions for /tarea folder. The User which is running the Apache server should have read/write permissions on the specific directories.

Setting up Apache

I'm setting up Apache server for elgg (an open source social networking framework) . I've installed apache2 on ubuntu and created a new file 'elgg' on 'sites-available' folder in /etc/apache2/ , copying the contents of default file already in that folder .I also changed the document root and directory setting inside the file and made no other changes .I enabled the site using a2ensite . But when i try to access the site through the browser it says - 403 forbidden , You cannot access this diectory . Is there something i did wrong ? I gave all users read ,write and exec permission in document root folder , still it's shown as forbidden
Check if one of the files specified as 'DirectoryIndex' is available and accessible, or if 'Indexes' is as Option.
Check for .htaccess files with possible 'Deny' conditions, or a Deny condition in your 'elgg' file in sites-available.
(Edit: removed 1, was already done)

777 permissions for public_html - Internal Server Error on some servers, but not others?

I have a few different servers, and on some servers, I can chmod the public_html folder to 777 permissions without problems - but on other servers, I get error messages. When trying to access the domain I get an Internal Server Error, and in my cpanel error_log on one server I get messages like the following:
Fri Oct 08 09:55:39 2010] [error] [client x.x.x.x] SoftException in Application.cpp:601: Directory "/home/managedi/public_html" is writeable by group
The reason I need to temporarily change the public_html permissions to 777 is so that a php script that executes the shell unzip command will work properly, and be able to extract files when accessed via URL.
Is there some server setting that causes 777 permissions for public_html to give an Internal Server Error? How can I get rid of this error while still changing the permissions for public_html?
Turns out this is because some servers have SuPHP enabled, while other servers do not. SuPHP can be enabled or disabled in cPanel WHM under: Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration
If SuPHP is disabled, then PHP runs as an Apache Module and executes as the user/group of the webserver, which is usually "nobody".

Resources