Amazon EC2 Ubuntu with Apache "Forbidden" 403 - apache

I am setting up an AWS Ubuntu server.
I installed apache2, mysql, php and phpmyadmin.
I can access files under /var/www
but not under /var/www/othersubfolder...
It will say: Forbidden.
I updated apache2.conf with:
<Directory /var/www/>
Allow from all
</Directory>
What am i missing?

If you're using apache 2.4+ you'll need to add this into your allow/deny rules:
Require all granted
So it would be
<Directory /home/user/path>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>

Related

Forbidden You don't have permission to access /dashboard/ on this server

I was able to reach http://myip, it is redirecting me to apache page.
But when am trying to reach var/www/html/dashboard am having this problem forbidden dont have permissions.
My httpd.conf is as below:
<Directory />
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
I have already disabled the SELinux:
SELINUX=disabled
I have also tried:
sudo restorecon -r /var/www/html
Nothing is helping me to solve my problem, can somebody please help me:
Allow the apache user read and execute permissions at every level of your DocumentRoot using chown or chmod at each level that is restricting the apache user.
Or, FollowSymLinks Option must be enabled for your directory in httpd configuration.
<Directory "/var/www/html/dashboard">
Options Indexes FollowSymLinks
</Directory>
Or, to diagnose, check file permissions using namei:
namei -l /var/www/html/dashboard

Ubuntu 14.04 Apache 2.4.7 404 Not Found

I've been reading the forums and trying to replicate their fixes, but I must be missing something on my end since it will switch from a simple 404 Error Not Found to a 403 Forbidden Error (even after chown and chmod changes).
Currently, I am experiencing the 403 error code even after a sudo apache2ctl restart
Here is what I've done so far.
- gedit apache2.conf with the following
<Directory /path/to/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 denied
</Directory>
gedit sites-available/000-default.conf && sites-enabled/000-default.conf
DocumentRoot /path/to/directory
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /path/to/directory>
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
Any help is much appreciated.
First note that you have now Apache 2.4, not Apache 2.2. The style to declare permissions has changed with Apache 2.4 and you should consistently use the new ones (like require all granted).
Apache has become more strict in what files it allows to be served. Essentially, arrange the files to be served outside in your Document Root and below, and keep all other files out of this tree. Don't link to files outside the Document Root tree.
Some point of your config:
<Directory />
This is the root directory of your file system. If you declare anything for it, it should be require all denied and nothing else. Note that there is a difference between a <Directory /absolute/path/to/some/directory> directive and a <location /relative/path/to some/location/on/your/server> directive.
Configure your server in terms of <location>

Correct way to enable .htaccess in Apache, Ubuntu 14.04.3 LTS?

I am trying to to enable .htaccess in Apache on Ubuntu 14.04.3 LTS by changing
/etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Also mod_rewrite is enabled.
But whenever i change AllowOverride None to AllowOverride All the site goes unresponsive and it keeps on loading.
What could be the possible reason? What is the correct way to enable .htaccess?
Steps would be like might helpful
open /etc/apache2/sites-available/000-default.conf and at the end on
the file BEFORE "</VirtualHost>" add this
<Directory /var/www/html/>
AllowOverride All
</Directory>
sudo a2enmod rewrite
sudo service apache2 restart

Changing root directory in apache2 is giving 403 Forbidden error

Though there are many similar questions here but I could not fix my problem from them.
I have installed Apache/2.4.7 (Ubuntu) in my ubuntu(14.04). I have changed two configuration files to change the default DocumentRoot of apache which is /var/www
to /home/name/www. The files I have changed are /etc/apache2/apache2.conf and /etc/apache2/sites-available/000-default.conf. In apache2.conf I put
<Directory /home/name/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and in 000-default.conf I changed,
DocumentRoot /home/name/www
My /home/name/www file has necessary permissions.
drwxr-xr-x 3 www-data www-data www
But when I try to access localhost from browser I receive
You don't have permission to access / on this server. error. What have i missed?
For changing the default root directory of apache from /var/www to /home/<username>/www following changes worked for me.
I edited the following values of etc/apache2/apache2.conf file like this. Before editing the file it's a good practice to keep a backup of the original.
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /home/<username>/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Then I changed /etc/apache2/sites-available/000-default.conf file's DocumentRoot.
DocumentRoot /home/<username>/www
After that restart the apache server,
sudo service apache2 restart

403 Forbidden on wamp server

I setup my wamp server and can access phpMyAdmin directory on the local host.
I'm trying to access a file from my directory but it gives me error 403 Forbidden yet I've tried to change my httpd.conf to
DocumentRoot "c:/wamp/www/"
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks ExecCGI
Order allow,deny
Allow from all
AllowOverride All
</Directory>
And I've also changed my phpadmin.conf to
<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
Options Indexes FollowSymLinks ExecCGI
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
Allow from MACHINE_IP
And I still can't access some files on my server
Here is the exact message:
Forbidden
You don't have permission to access
/php_sandbox/e-commerce/4-full-mvc-framework/views/login/index.php on
this server.
In your phpadmin.conf these lines are your problem:
Allow from 127.0.0.1
Allow from MACHINE_IP
change this to
Allow from all
and it should work.