HTTP Server Error 403. Forbidden - apache

I am getting the following error:
Forbidden: You don't have permission to access [directory] on this server.
I need direct access to this directory and sub folders on that directory so that my Android Application can communicate with it.
I tried putting folders on a Hosting Server and everything works fine.
But, I am doing an academic project and I need to store these folders and scripts on a University Web Server which can talk to localhost locally.

1.
If you have the possiblity and your server is a linux server, you can change the permissions with something like
sudo chmod -R 777 /var/www/folder
Or completely change the owner with
sudo chown -R user /var/www/folder
2.
Look into the apache configuration files and also the .htaccess, if the directory is blocked by
Deny from all
Or simply not allowed. You could allow the directory by creating a .htaccess file and enter
<Directory yourdirectory>
Order allow,deny
Allow from all
</Directory>

Related

Problems with network shares using Apache on Windows server 2019 Standard

I am replacing an old web server running IIS 7 (?) with a new server running XAMPP (Apache 2.4) on a Windows Server 2019 Standard machine. I have a couple of network shares with content I need to display, but I cannot get Apache configured correctly. I am calling one such network folder "eom".
I created a new user specfically to run the Apache service, the user account has network access, and I have the service running as that user. That user (as well as my own user account) has full control/access to the network folder identified below.
I have tried simply identifying the network location with a block, like this:
<Directory "//OLDSERVER/data/eom">
AllowOverride None
Allow from All
Options +FollowSymLinks
</Directory>
Alias /eom/ "//OLDSERVER/data/eom"
In this case, "/data" is a shared folder. If I try it with the drive letter identified like "//OLDSERVER/c$/data/eom", Apache doesn't like it. It says the path is invalid.
I have also tried creating a symbolic link called "eom" and pointing to the same folder with this command:
mklink /D eom \\OLDSERVER\data\eom
When I created the symlink, I commented out the block in the config file. Nothing is working. No matter how I try it, the response I get is "403 Forbidden You don't have permission to access this resource."
I have also tried starting the web service as myself, especially when testing the symbolic link, but I always get the same result.
Any help is appreciated.
FINALLY figured it out! The steps are (all from the web server):
make sure you have access rights to the content you are trying to share
find the IP address of the remote server with the needed content
ping -a \OLDSERVER
navigate to your web root folder, in my case "c:\xampp\htdocs".
use "mklink" to create a symbolic link:
mklink /D eom \10.20.30.40\data\eom
add block in your httpd.conf file:
<Directory "/eom">
AllowOverride none
Allow from All
Options +FollowSymLinks
restart Apache
Now you can test. There may be other ways to do it, but this is what has finally worked for me.

Unable to get access to specific directory to run a site on ec2

Still fairly new to ec2, I made a new directory as /home/user/www. Opened ftp service that allows git commits to be pushed to the server. This works fine as I can see the files come up. The problem being when I run my site, the Apache test page pops up and when I try opening a page in /home/user/www directory, it says Forbidden, you don't have permission to access / on this server.
I have successfully changed the DocumentRoot
DocumentRoot "/home/user/www"
AllowOverride None
# Allow open access:
Require all granted
and Directory in httpd.config to /home/user/www, all but to no result.
Any help is appreciated. Permissions are 777 for test basis but still no success. User is the owner of all the files in www
Solved my own question. Permissions need to be set on the third directory i.e., www. Therefore, I did chmod 755 ~/www.
Worked like a charm

PHPmyadmin and Wordpress directories access denied

Running wordpress locally on a centOS 7 server running the latest apache, PHPmyadmin and mariadb-server.
IP/wordpress and IP/phpmyadmin on systems within the local network yields "403 forbidden" "you dont have permission to access (directory) on this server."
How can I fix this to allow the website to be seen on the public internet?
Could be a lot of things.
In your main Apache configuration file (e.g. /etc/httpd/conf/httpd.conf on Arch Linux), confirm your DocumentRoot path. The files you want to serve must reside there, or in sub-directories from there (If not, you might want to use an Alias to specify another path). Since you call IP/wordpress and IP/phpmyadmin, then you probably have directories called wordpress and phpmyadmin under your DocumentRoot path.
You also want to check the Directory groups in your Apache configuration file. Under those, the main culprit would be the Require directive set to all denied or something else too much restrictive like ip your_ip.
Finally, PHP can restrict path access with the open_basedir directive. Look for it in your php configuration file (e.g. /etc/php/php.ini on Arch Linux). If the line is commented, you're fine. But if a path is specified, your wordpress and phpmyadmin files must reside there.
Depending on your setup, any directive mentioned above could be in another Apache configuration file (e.g. /etc/httpd/conf/extra/* on Arch Linux).
Take a look at Apache and PHP online documentation for information about those directives.
Probably there is an issue with your directory privileges.
Use the follwing command to check it:
cd your_site_directory
ls -l
You can have a look to have a better understanding on directory privileges here.
As mentioned here apache runs under "apache" user.
Have a look at this post here to fix the issue.
All files should belong at least to apache group. To do it you can use
cd your_site_directory
chgrp -R apache ./*

Apache Access denied after changing the web root permissions

I recently changed the document root permissions to everyone using this command:
sudo chmod -R 753 /var/www
But not when I access the website, I get the error.
You don't have permission to access /index.html on this server.
I tried modifying the http.conf to allow access but nothing happened. Basically, how do i undo this command?
You need to allow access to apache user and group for your /var/www directory to work your sites. You need to assign 755 permission to your /var/www directory

Apache can't serve DocumentRoot : no execute permission error

I am trying to migrate a web application from a Slackware config of Apache to a CentOS 7 one. DocumentRoot set to /home/STORAGE and there is a simple index.html file in it for testing. Both /home/STORAGE and index.html have 777 permissions set, yet Apache reports :
access to /index.html denied ... because search permissions are missing on a component of the path.
On the other hand, phpMyAdmin works fine, configured with a separate .conf file in /etc/httpd/conf.d . I tried using their example to make a .conf file for my app, but it still reports the same error. I don't even know where to start looking here.
EDIT:
I think this has something to do with the user of Apache. It is set to a local user in httpd.conf not to root, but the only pages the server serves are those in directories owned by root.
It was not a permission error but a Selinux issue. I decided to use the default /var/www/html for the application but still, had to allow write access to some dirs. Here is what I typed:
sudo chcon -t httpd_sys_rw_content_t /some/dir/in/var/www/html -R
The first time I typed it without -R and the permissions didn't change (check with ls -Z /dir/path). Now it is fine.