how to configure apache to run pages with a different group id than files - apache

I have a vps with godaddy with the following:
centos 6
latest apache
whm/cpanel
I am running with suphp enabled.
files and folders are all 755,644
i have a program located at:
/home/programname/public_html
this program edits files located on the same server in different user accounts. in order for this to happen i have to:
chown programname:programname /home/username/public_html
this allows the files to be edited by the program running at /home/programname/public_html
when i try to view the files at
/home/username/public_html
at its domain name
username.com
I get an "The server encountered an internal error or misconfiguration and was unable to complete your request."
in order to fix this i have to
chown username:username /home/username/public_html
how do i fix this so i can view the website files without having to chown the files?

You can use ACLs:
Enable ACLs on a filesystem:
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-acls.html
Set ACLs on a filesystem:
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/acls-setting.html
There is also an apache module that I haven't had much luck with:
apache2-mpm-itk - http://www.webtatic.com/packages/httpd-itk/
It has some issues because it doesn't support prefork properly.

Related

apache subprocess can't access files

i'm running into a problem where a program written to be accessed as a web service can't access anything in the local file system. running the program from the command line works correctly, but fails when called via apache as a subprocess exec'd via system() from a php script ; it simply can't find the files it's supposed to work on. i'm convinced this is an apache configuration issue, as the program has no problem reading /var/www/html [the webserver document root] and any/all files/directories under it.
here are some details :
virtual centos 7 server running apache 2.4.6.
the program runs as user apache
it can read / [root dir] and interprets it correctly [i.e. it really is / the system root, not /var/www/html]
it doesn't have access to /tmp at all, nor to /var/tmp
some external files are network mounted on /mnt. the program can access /mnt, but attempts to read /mnt/{anything} fail -- even though remote shares are mounted w/effective uid/gid as apache and all files/directories are readable by world.
selinux is currently disabled
for kicks, i tried setting Require all granted inside <Directory / > and <Directory /tmp > in httpd.conf, but that didn't change anything.
does anyone have any idea what could be causing this and how i could fix it ?
thanks.
Have you checked to see if selinux is restricting access?
You can see if Selinux is causing issues by install selinux troubleshooting
yum install -y setroubleshoot
sealert -a /var/log/audit/audit.log

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

Access forbidden on apache2 on ubuntu14.04

I have installed apache2 server on Ubuntu 14.04. It is working well with the files and directories which i have created here after installation, but if i copy any file or folder from anywhere else (already written) then is gives Forbidden error message.
Thanks in advance.
For a file to be accessible by apache2, it should be owned by the user which runs the apache2 server. On most systems the user is www-data or httpd or apache. To find which user is that, just look into your apache2.conf or httpd.conf. Once you know the user, make it the owner of the copied files/folders or reiterate it for the whole /var/www//html folder.
sudo chown -R www-data:www-data /var/www/html
This should do it. But, if it doesn't, verify that the user has at least read and execute permissions on the folder (write also, if you need to write some data through your script).

Apache 403 on certain folders

I'm running dev server on Centos 6.4 with Apache 2.2. I just moved a site from the production to dev to perform upgrades. I modified file owner to apache:apache (httpd user) and set all directories to 755 and files to 644. I have few other sites in the DocumentRoot folder with similar settings and they run fine (using same CMS, PHP, MySQL versions etc).
I have no virtual hosts defined and Allow all on everything. httpd.conf is default.
I'm not able to make site working from the folder I just moved from the production. I'm getting 403 every time.
As suggested in
https://serverfault.com/questions/272947/apache-on-centos-5-6-gives-me-permissions-denied-error/272956#272956
Usually that comes from Selinux not giving access to the folder. do
ls -alZ /var/www
and if the html folder doesn't have the context system_u:object_r:httpd_sys_content_t, fix it with chcon
chcon -v -R --type=httpd_sys_content_t /var/www/html
http://wiki.centos.org/HowTos/SELinux

Does Apache need to be stopped to edit "/etc/apache2/sites-available/default"?

I am attempting to edit the "default" file located at ..
"/etc/apache2/sites-available/default"
on my Ubuntu machine running Apache 2.2.8.
I want to do this in order to enable the use of .htaccess files. I have downloaded the "default" file and edited it and now I am trying to upload it back to the server via SFTP. I keep getting permission denied errors.
Could it be because Apache is running and making use of the file? I am an admin on the machine so I would expect to be able to overwrite the file. Thanks for any assistance.
No it does not need to be stopped.
Try accessing the file through ssh, and make sure you access it with root privileges:
sudo nano /etc/apache2/sites-available/default
You would still need to force-reload Apache after changing the config files, as tux21b suggested in a comment below:
sudo /etc/init.d/apache2 force-reload
For Apache/2.4.7 , the file that you want to edit is:
/etc/apache2/apache2.conf