Apache in Debian Jessie - still get message You don't have permission to access / on this server - apache

The same virtual config i apache wheezy works right.
For example:
ServerName lgbs
ServerAlias www.lgbs
DocumentRoot /home/vdomain/app/web
SetEnv APPLICATION_ENV "development"
<Directory /home/vdomain/app/web>
# enable the .htaccess rewrites
AllowOverride All
Order allow,deny
Allow from All
</Directory>
But on Debian testing 'Jessie' i still get message:
Forbidden You don't have permission to access / on this server.
Apache/2.4.9 (Debian) Server at test Port 80
Of course a check file permision and i set rwx for evryones and owner and group is www-data.
Thanks for help

This drove me crazy for a couple of hours. Apparently in 2.4.9 ( I upgraded from 2.2.2 ) there is a "Require all granted" that you need to add to each directory.
In my http.conf:
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
So basically what I had to do was:
<Directory "/Users/johndoe/Sites">
Require all granted
</Directory>

Related

Ubuntu | Apache - No permission to request ressource after changing DocumentRoot

I am currently setting up a development environment with Apache and Ubuntu for a Git project.
However, when I adjust the documentRoot under sites-availabe, I get the message "403 Forbidden" by calling the site in the browser.
The default directory under /var/www/html can be displayed without any problems.
However, if I change the path to /var/www/my-project.com, I get the 403 message.
I also copied the permissions from the folder "html", so there shouldn't be any problems here.
000-default.conf
ServerAdmin xxx#xxx.xx
DocumentRoot /var/www/xxxxx.com
ServerName xxxxx.com
ServerAlias www.xxxxx.com
apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
/etc/hosts
127.0.0.1 localhost
127.0.1.1 hostname
127.0.0.1 xxxxx.com
Permissions of /var/www/xxxxx.com
drwxrwxr-x 7 user:www-data
I have also completely reinstalled Apache, but that didn't help either.
(Im using Ubuntu 20.04 with Apache 2.4)
I would be very grateful for any help.
Edit: Also after copying the files to the html directory ends up in 403 when calling specific files. But i still can call the standard index.html from apache.
I found my problem. Because im really new to Ubuntu i didn't recognized the broken Symlink. After recreating it with
ln -s sourceDirectory newLinkDirectory
all works just fine

WampServer: 403 Forbidden

All of a sudden my local WampServer vhosts are not working.
I've added a new vhost to vhosts.conf and hosts.
When I load that vhost in a web browser, I receive 403 Forbidden.
In vhosts.conf, I have:
<VirtualHost *:80>
ServerName example.com.au
ServerAlias example.com.au
DocumentRoot "D:\Dropbox\WAMP\WWW\example.com.au"
<Directory "D:\Dropbox\WAMP\WWW\example.com.au">
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
</VirtualHost>
In httpd.conf I have:
Listen 10.0.0.199:80 ::1
Listen [::0]:80
<Directory />
AllowOverride none
Require all denied
</Directory>
where 10.0.0.199 is my PC's IP.
WampServer is online.
WampServer 3.0.6
Apache 2.4.23
Help appreciated.
I changed
<Directory />
AllowOverride none
Require all denied
</Directory>
to
<Directory />
AllowOverride none
Require all granted
</Directory>
in httpd.conf, and that resolved the 403 error.
The default config in httpd.conf has all the Listen parameters you need
Listen 0.0.0.0:80
Listen [::0]:80
This says listen on port 80 of whatever this PC's ip address is for both IPV4 and IPV6 address ranges, and is all you need.
This section of httpd.conf should also be left as you found it. This sets up the basic denial of all rights to all folders on the drive where you installed WAMPServer(Apache) and should do exactly that. Change it back to this
<Directory />
AllowOverride none
Require all denied
</Directory>
This is for your security. It say nobody is allowed access to the root of this driver and therefore no access to anything below the root. Once this is set you are then supposed to open up access to ONLY what Apache actually need access to. That is what you do in your httpd-vhosts.conf file for only the folders that site requires access too.
If you are hacked, then a hacker can only access those folder given access and NOT YOUR WHOLE DRIVE.
Your Virtual Host definition in httpd-vhosts.conf shoudl look like this
<VirtualHost *:80>
ServerName example.com.au
ServerAlias www.example.com.au
DocumentRoot D:/Dropbox/WAMP/WWW/example.com.au
<Directory "D:/Dropbox/WAMP/WWW/example.com.au/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
## Dangerous unless you really mean to
## allow the universe into your server
## I would use one of the other options and comment this one out
Require all granted
# If access from this PC only then us
# i.e. you are a standalone developer
# uncomment this
#Require local
#If access from your local network is required
# i.e. you are working with other devs within your local network
# uncomment this
#Require ip 10.0.0
</Directory>
</VirtualHost>
Note the use of Unix forward slashes and the <Directory.... tag needs a trailing slash
Then check your HOSTS file it should be like this
127.0.0.1 localhost
::1 localhost
127.0.0.1 example.com.au
::1 example.com.au

in my apache2 site pointing only working /var/www/ only how to point outside the /folder in ubuntu(/root )

Forbidden
You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at ovenfresh.codilar.net Port 80
my path /home/oven/www
in apche2 configuration file u have to add the folder
/etc/apache2/apache2.conf
then add this line
<Directory /bar/bhtl/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
you can add your path

Apache Document Root adds leading default path

This should be a very simple question to answer for people who knows apache.
I have an Ubuntu computer which I use as my server. I have worked with apache several times before, but never experienced this issue.
My owncloud.conf file in the sites-enabled folder looks like this:
1 <VirtualHost *:80>¬
2 ServerName owncloud¬
3 DocumentRoot "~/mybook/ownCloud"¬
4 <Directory ~/mybook/ownCloud/>¬
5 Options None¬
6 Order deny,allow¬
7 Allow from all¬
8 </Directory>¬
9 </VirtualHost>
But after enabling the site and restarting apache, I'm getting this error:
AH00112: Warning: DocumentRoot [/etc/apache2/~/mybook/ownCloud] does not exist
I've been looking, and I cannot seem to find where it's set that "/etc/apache2/" should be leading default path to all set document roots of the site config files.
Does anyone know how I can remove this default setting?
Forget the comment I made regarding Mac, what you have above will not work. If you installed Apache on Ubuntu and accepted the defaults the docroot is /var/www and I am assuming you want your /mybook/ownCloud mapped to docroot. That is how you should do it because the httpd will run with group permissions to the real docroot. That can be done using an alias as I have below. Look at the bottom, but also note that I specified the correct default docroot in the beginning before I mapped anything. You can change the docroot but you will have to make sure the permissions on the new directory structure are set correctly.
I aliased your /mybook/ownCloud/ to ownCloud. Also, I have other directives that I removed from the sites-enabled code below for clarity.
BTW, I have personally never used tildes within an Apache conf file like you have above, it could be confusing during startup.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /owncloud/ "/mybook/ownCloud"
<Directory "/mybook/ownCloud">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
EDIT:
There are other ways to configure a VHost, but this is basically how it is done. You no longer set a server wide docroot declaration in httpd.conf. The /etc/apache2/ path is the server home and in the absence of a docroot declaration in your sites-enabled it may have defaulted to Server Home when httpd started.

apache: don't have permission to access / on this server. when I am using virtualhost

For example, the document root of virtualHost is /var/www, and server name is aaa.com.
However, apache will tell me forbidden if I access the server with localhost and aaa.com. If I change the Directory option in http.conf to /var/www, apache will work well. I don't know why?
I want to set Directory option in every httpd-vhosts.conf, not in httpd.conf, how I can do it?
Here is my http.conf:
Here is my httpd-vhosts.conf:
In http.conf file you should define options for only <Directory />. All the options of VirtualHosts you should define in httpd-vhosts.conf files. Something like:
httpd.conf:
DocumentRoot "/var/www"
<Directory />
Order deny,allow
Deny from all
Options None
AllowOverride None
</Directory>
httpd-vhosts.conf:
ServerName aaa.com
DocumentRoot /var/www
<Directory /var/www>
Options FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
This configuration was valid for apache version 2.2
First check your apache version by typing apachectl -V in your terminal.
If it shows something like this
Server version: Apache/2.4.27 (Ubuntu)
Server built: 2018-04-18T14:20:05
then your apache version has updated but the conf you are using is deprecated.
So instead of
2.2 configuration:
Order allow,deny
Allow from all
use this:
2.4 configuration:
Require all granted
For further documentation related to the upgrade, follow the official docs:
http://httpd.apache.org/docs/current/upgrading.html
2.4 configuration:
<Directory />
Options All
AllowOverride All
</Directory>