As title said, I got error 403 (title of page) on Laravel project. Locally, it's working, but when I'm trying to put it live, on a web-host/my domain it gives me:
Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I deleted .htaccess file from public folder, and nothing happened.
Any solutions?
Your .htaccess is not parsed by apache because AllowOverride All directive is missing inside virtualhost configuration. .htaccess file is required for Laravel. Put back it. Then change apache virtual host configuration on server to allow .htaccess.
<VirtualHost *:80>
ServerName www.example.net
DocumentRoot "/var/www/html/example3"
<Directory /var/www/html/example3>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Change your virtualhost like this and restart apache by sudo service apache2 restart.
Replace www.example.net and /var/www/html/example3 with correct details.
If you are using your own Request, change the authorize function to return true:
public function authorize()
{
return true;
}
As simple as that!
You can try these commands.
sudo chmod -R gu+w project_folder
sudo chmod -R guo+w project_folder
chmod -R 775 storage/
chmod -R 775 bootstrap/cache
Related
I'm trying to use laravel storage API. I can make directory and save files on storage/app/users/user_id/filename but when i want to use files on web page i get forbidden 403. I made a symbolic link:
ln -s storage/app/users public/users
I checked all permissions and they are fine. I changed all permissions to 777 but nothing changed. Here is my apache configuration for this virtual server:
<VirtualHost *:80>
ServerName kamel.dev
DocumentRoot "/home/morteza/development/repo/kamel/public"
<Directory /home/morteza/development/repo/kamel/public>
AllowOverride All
Options FollowSymlinks
Order allow,deny
Require all granted
Allow from all
</Directory>
</VirtualHost>
Chrome error message when i use files:
GET http://kamel.dev/users/2/phpDiLp1O.jpg 403 (Forbidden)
And this is apache response for calling url directly:
Forbidden
You don't have permission to access /users/2/phpDiLp1O.jpg on this
server.
The problem was in how i made symbol link. Here is create symbolic link command:
cd public
after going to public directory use this:
ln -s ../storage/app/users users
I have installed a virtual machine CentOS 6.6. I also installed Apache, PHP, MySQL with yum.
I changed my document root from /var/www/html to /www
so I edited my /etc/httpd/httpd.conf and changed these two lines:
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
I restarted apache and it was okay.
The problem occurred when I tried to open http://192.168.199.90/phpinfo.php.
I got:
Forbidden
You don't have permission to access /phpinfo.php on this server.
I tried to disable SElinux in /etc/selinux/conf and change enforcing to disabled
I also tried this: chcon -v -R --type=httpd_sys_content_t /www/
And when I write ls -laZ /www, I have:
drw-rw-rw-. www www unconfined_u:object_r:httpd_sys_content_t:s0 .
dr-xr-xr-x. root root system_u:object_r:root_t:s0 ..
-rwxrwxrwx. root root unconfined_u:object_r:httpd_sys_content_t:s0 phpinfo.php
drw-rw-rw-. www www unconfined_u:object_r:httpd_sys_content_t:s0 sites
Thank you all , i resloved it,
I changed the Current mode of SElinux
from enforcing to permissive by wrinting in the terminal :
setenforce 0
so when i write
getenforce i get Permissive
I did also chmod 755 -Rf /www
;)
Edit httpd.conf file, which is in /etc/httpd/conf/httpd.conf. Add the below code.
<Directory "/var/www/html">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Allow from all
</Directory>
Try:
chown -R apache:apache /www
or
chown -R www-data:www-data /www
BTW, never disable your SElinux
I have a symlink mysite in my /srv/http/ folder pointing to /home/some-user/somefolder.
In my /etc/httpd/conf/httpd.conf, according to many thread in this site and other forums all around the Internet, I set the following:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
DocumentRoot "/srv/http"
<Directory "/srv/http">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Then I changed permission to 777 recursively to my symlink target folder like this:
chmod 777 -R /home/some-user/some-folder
But if I open my webbrowser and enter http://localhost/mysite/mypage.php I get the following error:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.9 (Unix) PHP/5.5.14
I've read many articles saying to do so, but I still can get it working...
You should chmod o+x the entire path where apache'd go through.
So in your case:
sudo chmod o+x /home/
sudo chmod o+x /home/some-user/
sudo chmod o+x /home/some-user/somefolder
Ok, found out! I needed also chmod o+x /home/some-user (parent folder to my site folder)
Just backed up a site to my local computer using CPanel.
I unzipped the file then placed it in /var/www.
Now my problem is that when I try to access HTML/PHP files from the public_html folder for the site via a browser (localhost/ndovucard/public_html/modules/contact_us.php), I get the 403 Forbidden Error by Apache2 server, and yes I did sudo chmod 755 /var/www.
Thanks.
There are can be several reasons why you are getting **403 Forbidden Error **
First check out weather you are denying permission to an .htaccess file and
that your apache2 is configured to allow htaccess file overide.
Check out your apache2 sites-available by using this command
in order to make your .htaccess files ( if you have any) work as expected, you need to edit this file:
sudo gedit /etc/apache2/sites-available/default
and then Look for a section that looks like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None // change **`None`** to **`All`**
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
. You need to reload Apache in order this change to have an effect:
sudo /etc/init.d/apache2 reload
OR
sudo service apache2 restart
If that is not the case, you have have permission set not correctly as you have said .
sudo chmod 775 /var/www/yourProjectFolderHer* -R
Hope that may help
sudo chmod 755 -R /var/www
and show your /var/log/
I have installed xampp to Ubuntu 12.04. I have put my project in the folder /opt/lampp/htdocs/project_is_here
When I type in the browser localhost/soap/php (soap/php is in my htdocs folder) which is where index.php I get the following error:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.3 (Unix) OpenSSL/1.0.1c PHP/5.4.7
Any ideas how to fix this? I think this is the right location to put the project, because I tried other places and it said location didnt exist and this error goes away here and I get this.
Any ideas?
In the linux terminal navigate to your lampp directory.
cd /opt/lampp
In the command line type:
sudo chmod 777 -R htdocs
The problem should be solved.
What you just did was:
Navigate to the directory containing the protected directory. Your problem was that it was a folder that was access protected by your system. When you commanded chmod 777 -R htdocs, you set the permissions for every user on your computer to "read/write/execute - allowed".
Each number from 0-7 sets a permission level. Here's a link explaining that in more detail.
http://www.pageresource.com/cgirec/chmod.htm
The '-R' makes the command recursive and will affect htdocs as well as all subdirectories of htdocs and all subdirectories of those etc.
i've experinced the same problem and this is my solution :
1.in the terminal
cd /opt/lampp/etc/
if you have sublime text installed simply just type :
subl httpd.conf
3.when the configuration file opened in sublime you have to check if these three blocks are as follow :
<Directory />
AllowOverride All
Require all granted
</Directory>
================================
<Directory "/opt/lampp/htdocs">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted
</Directory>
================================
User your username
Group your group name
for example :
my username is mhmd also my group name is mhmd
User mhmd
Group mhmd
and i hope it will help you ..
One possible reason is that you are using Virtual host.
In that case, use this command in your terminal
sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf
Then add this block of code at the end of the file
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error_log"
CustomLog "logs/localhost-access_log" common
</VirtualHost>
Finally restart XAMPP
sudo /opt/lampp/lampp restart
I had given all the permission , still got the error message.
Go to -> /etc/apache2/sites-available/000-default.conf
set : DocumentRoot to /opt/lampp/htdocs
All solved for me.
Change the "DocumentRoot" to whichever folder your project is.
it'll useful,
0 -> No permission
1 -> Execute
2 -> Write
3 -> write and execute(2 +1)
4 -> Read
5 -> Read and execute
6 -> Read and write
7 -> read,write and execute
Then What about three decimal
1st-digit Owner
2nd- digit Group
3rd- digit Others
test#test:~$ sudo chown -R test:test /var/www/html/folder
test#test:~$ sudo chmod -R 666 /var/www/html/folder //-system user
test#test:~$ sudo chmod -R 777 /var/www/html/folder // -browser with full
What is this 777 ? --> 7: you, 7: us, 7: them.