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/
Related
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
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)
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.
I'm new to .php and servers and all this craziness (and StackOverflow) but I've downloaded Apache and I'm trying to symlink a PHP code folder to the Apache root directory. My Apache root was var/www/html and my PHP code folder is Documents/PHPStuff. I renamed var/www/html to var/www/html2 and I made a symlink in var/www/ called 'html' which links to Documents/PHPStuff, thinking if I renamed the symlink to the name Apache is looking for then it would work.
It doesn't.
When I try to access my test file in Documents/PHPStuff called 'helloworld2.php' in my browser with 'localhost/helloworld2.php' I get a 403 Forbidden Error.
I've been messing with permissions on the symlink and in the PHPStuff directory, changing them to 777 and stuff but it hasn't worked. I also changed my httpd.conf file by changing FollowSymlinks None to FollowSymlinks All. Nothing has worked yet so this was my last resort.
Try to don't touch your http.conf. Instead, edit files from conf.d path.
To grant access to your home paths, edit your /etc/http/conf.d/userdir.conf to activate user dir option, like:
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public_html
</IfModule>
<Directory "/home/*/public_html">
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
then, restart your apache.
Now, you have to create a directory /home/$USER/public_html and create into it the symlink to your ~/PHPStuff, like
ln -s ~/PHPStuff ~/public_html/PHPStuff
You can move PHPStuff to ~/public_html/ instead create the symlink.
Ensure that your homedir have 711 permissions, public_html have 755 and the dirs and files inside PHPStuff are readable by everyone.
Finally, type into your web browser
http://localhost/~user ('user' is your system username)
and you will see your PHPStuff listed. You can type
http://localhost/~user/PHPStuff
to view the PHPStuff content directly.
Good luck!
You shouldn't need to do all of that.
This is how I set up my symlinks.
When I install apache, it's web directory is located at /var/www/html which doesn't really need to be changed.
Then, I create a folder called public_html, you can call it PHPStuff, doesn't matter. What matters is that the folder is inside your home directory, so /home/your_username/PHPStuff
Then link that directory to /var/www/html
sudo ln -s ~/PHPStuff /var/www/html/$USER
You can then access ~/PHPStuff by going to your browser, and typing:
http://localhost/your_username
Which will give you access to ~/PHPStuff
After you do that, set proper permissions:
sudo chmod -R 777 ~
Then make sure apache allows symlinks by going to /etc/httpd/conf/httpd.conf and editing this portion Directory "/var/www/html"
And make sure you have these:
Options Indexes FollowSymLinks
AllowOverride All
Restart apache and everything will work.
You need to make sure apache has access to the folder that the symlink is pointing to, try running:
chmod a+x /home/your-username /home/your-username/Documents/PHPStuff