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

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

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.

Laravel Ubuntu 16.04 returning status code 500

I just deployed a Laravel project I developed at localhost (using XAMPP) to a server.
I uploaded all files, created a new .env file (also got an app-key), ran composer install, created the db, ran artisan migrate.
Also, in
/etc/apache2/sites-enabled/000-default.conf I set the DocumentRoot to the public directory of laravel. Also I tried to edit the apache2.conf to include the directory, with Allowoverride All.
But entering the ip of my server, I get redirect to the login page (of course, I'm using the Auth of Laravel).
But I'm getting the error:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I tried to follow those steps, but it's all the same. Except the one point, that in my apache2.conf I don't wrote the DocumentRoot anymore, as I already set it in the 000-default.conf. I also tried to set it a second time in the apache2.conf, but this changed nothing.
So what couuld the problem be?
I'm using Ubuntu 16.04.
PS: Something seems to happen inside of laravel. When I go an existing route, I always get this error code 500. When I go to a route, that doesn't exist, I get an error (NotFoundHttpException), so the Routing itself kinda seems to work, but where does this error come from? It are exactly the local files I'm using with XAMPP, and locally it works fine... Any ideas?
EDIT: After editing my logs directory to have permissions like 777, I'm getting 2 errors as well.
Both point to storage/framework/views/ and storage/framework/sessions, saying "Permission denied". Do I just have to run chmod for those directories as well?
Check the error in storage/logs/laravel.log if there is no log there then make sure your directory permissions for storage allows it to be writeable 775 is what I normally use.
Okay, I got it, basically it was the permissions.
I now changed the owner of the storage folder to www-data. Now it's working (for anyone that might experience this problem, too).
if you use vps ubuntu, you have to set write/read permission with root folder (and all file, folder of it) by using this command on putty:
chown -R www-data:www-data /var/www/html
i tried this command, and my website doest not show 500 error

Is there any reason that the apache webroot /var/www/html is set as root-owned?

I just launched a LAMP dropplet from Digital Ocean and am starting coding. When trying to create a new directory inside the web root it says
mkdir: cannot create directory ‘blog’: Permission denied
I can fix this by running chown -R user /var/www/html but I'm wondering if this will break things or if there's a better way of doing this. Thanks!
You have a variety of options on permissions, but essentially www-data needs read (and probably execute) permission.
I like to redefine the DocumentRoot in my VirtualHost definitions to use something other than /var/www/html, anyway.
For example, you could use /srv/www/sitename, and then assign permissions myuser:www-data to it.
There are also numerous threads on the DigitalOcean forums (and around the internet) about permissions schemes for web files. (e.g. Proper Permissions for Web Server 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.

HTTP Server Error 403. Forbidden

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>