How do I make Apache read symlinks to different partition? - apache

I have Linux Mint 13 with two ext4 partitions, one for / and one for /home. I just installed LAMP. It works fine except that Apache won't read symlinks that target the second partition. The server's document root is set to /var/www.
What I'm trying to do is create symlinks for each website in www to link to /home/my-username/Documents/mywww/website_name so I can access it via localhost/website_name.
I enabled FollowSymLinks and removed SymLinksIfOwnerMatch. I also gave 777 permission to the symlink itself and to the mywww folder and all its contents. But it just doesn't work.
The error log says "Symbolic link not allowed or link target not accessible". Setting the document root to /home/my-username/Documents/mywww/website_name also diesn't work and prints "(13) Permission denied: Access to / denied" to the error log.
I hope someone can help me out here.
EDIT: added some paragraphs

This sounds like a permission/ownership issue if you have Options FollowSymLinks already set in httpd.conf. What are your permissions for the Documents dir? Its usually 700 by default. Setting it to chmod 705 or chmod 755 may work.

Related

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 ./*

Document root must be a directory RHEL6

Respected Members,
I am a newbie to linux. Preparing for my RHCSA exam. I have an error in apache conf which I am unable to solve it. If any member gives me any suggestion regarding this, it will be a great help.
Okay so here is the task which I am trying to perform:
******* YUM Server With HTTP *****
I have copied the whole RHEL6 dvd into my desktop in a directory called "rhelrepo". After that created a database with "createrepo" inside "Packages" folder. Modified httpd server config file with Alias "/repo" pointed towards the directory "/home/admin/Desktop/rhelrepo".
Created directory
order allow,deny
allow from all
Options Indexes FollowSymLinks
Disabled selinux, firewall. Restarted the httpd service, it is not accessible. After that I changed the Document root to the appropriate folder /home/admin/Desktop/rhelrepo , it says that "Document Root Must Be A Directory".
I am struggling to find the solutions for this. I have applied the solutions which is provided in this forum but still no luck. Will appreciate any help from the members
Thanks
This is typically either an SELinux issue or a typo in your configuration. Please check that the documentroot directive does not contain any weird quote characters or full stops or the like. If possible, post your actual DocumentRoot configuration line in this question.
Also, you could run namei -m /home/admin/Desktop/rhelrepo to make sure the system sees your directory as an actual directory.

Set Apache to allow access for a directory not under document root

My only virtual host in Apache has /var/www/html as its document root, that html is a symbolic link to something like /home/yanzs/web/some-project/. I am doing this so that I can easily work on a new web project without create a new virtual host in apache. So here is my problem, when I access localhost, it says
Forbidden
You don't have permission to access / on this server.
How can I set permissions for that "/home/yanzs/web/some-project/" directory, or better its parent directory "/home/yanzs/web/"?
Here is the default setting for /var/www/ directory, does the FollowSymLinks option automatically set permissions for directories that are the targets of symbolinks under /var/www?
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Update: I also tried to use the Alias setting, does not work either.
Update 2: If I set the document root as /var/www/html, and create a symbolic link under html directory, pointing to /var/www/project. Then it works, and the Alias method works too. It seems that it has something todo with the owner or other file permission settings. All files and folders under /var/www are owned by root, while those under /home/yanzs/web are owned by yanzs.
Solution:
It turns out that permission on all parent directories matters, too. One of the parent directory is copied from Windows and does not have the required permission by default. See (13) Permission Denied for more details. One lesson learned is never forget to check the error logs, even if you know permissions are relevant from output of browser.
It turns out that permission on all parent directories matters, too. One of the parent directory is copied from Windows and does not have the required permission by default. See (13) Permission Denied for more details. One lesson learned is never forget to check the error logs, even if you know permissions are relevant from output of browser.

How to setup FollowSymLinks?

I am trying to have Apache follow a symlink to a raid array server that will contain some large data files. I have tried modifying httpd.conf to have an entry like this
<Directory "/Users/imagine/Sites">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
to have Apache follow any sym link in the Sites folder.
I keep getting an error return that seems to indicate I don't have any permissions to access the files. The error is:
Forbidden
You don't have permission to access
/~imagine/imageLibraryTest/videoClips/imageLibraryVideos/imageLibraryVideos/Data13/0002RT-1.mov
on this server.
The sys link file is the last "imageLibraryVideos" in the line with the Data13 being the sub dir on the server containing the file.
The 0002RT-1.mov file hase these permissions:
-rwxrwxrwx 1 imagine staff 1138757 Sep 15 17:01 0002RT-1.mov
and is in this path:
cd /Volumes/ImagineProducts-1/Users/imagine/Sites/imageLibraryVideos/Data13
the link points to:
lrwxr-xr-x 1 imagine staff 65 Sep 15 16:40 imageLibraryVideos -> /Volumes/ImagineProducts-1/Users/imagine/Sites/imageLibraryVideos
I had the same problem last week and the solution was pretty simple for me.
Run:
sudo -i -u www-data
And then try navigating the path, directory by directory. You will notice at some point that you don't have access to open the dir.
If you get into the last directory, check that you can read the file (with head for example).
Look in the enclosing directories. They need to be at least mode 711. (drwx--x--x)
Also, look in /var/log/apache2/error_log (Or whatever the concatenation of ServerRoot and ErrorLog is from the httpd.conf) for a possibly more-detailed error message.
Finally, ensure you restart apache after messing with httpd.conf.
You should also look at bind mounts rather than symlinks - that would allow you to remount a given path at a new point. The following is an example:
mount --rbind /path/to/current/location/somewhere/else /new/mount/point
You can also edit your fstab to do this at boot:
/path/to/original /new/path bind defaults,bind 0 0
This is a permissions problem where the user that your web server is running under does not have read and/or execute permissions to the necessary directories in the symbolic link path. The quick and easy way to check is to su - web-user (where web-user is the user account that the web server is running under) and then try to cd into the path and view the file. When you come across a directory that you don't have permission to enter, you'll have to change the permissions and/or ownership to make it accessible by the web server user account.