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

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

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

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).

How to set which folder to load with apache2 server?

My friend introduce me Linode and register.com, so I am playing with it now. I already get a domain name, while on my Linode server I am trying to set up a basic webpage so I can start to use it for my personal website. I'm following http://library.linode.com/hosting-website#sph_web-server to set up.
Here's the question, I made a testsite folder on my linode server, and a /etc/apache2/sites-available/testsite file which can be called at sudo a2ensite testsite command. (All of these are part of the tutorial.) But when I wish to switch the content for that website, I created a testsite1 and a /etc/apache2/sites-available/testsite1, then I do sudo a2ensite testsite1, but I don't know how to let the apache read the content from my testsite1 folder instead of testsite folder. The way I did that is I try sudo a2dissite testsite, so then the content in testsite1 can be read. But I hope there is better way to do that. Also I've heard apache2 can handle multiple server at the same time. How to assign which server load which folder on my linux machine? (For example, if I have abc.net and efg.net, I already link both of them to my linode server, how can I let abc.net go to read the abc folder in my linux server, while the efg.net load my efg folder?) Thanks.
You need to edit the httpd.conf file usually found in /etc/apache2/conf. Then edit the httpd.conf file and look for "Document Root" setting in this file. Change it to /etc/apache2/sites-available/testsite1 and then restart apache: /etc/init.d/apache2 restart

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

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.

Trac after clean install. TracError: IOError: [Errno 13] Permission denied

I have clean CentOS 6. I just install via yum install httpd mysql-server, python, mysql-python.
First Step
$ trac-admin /home/tracprojects/main2 initenv
Project name: Main
SQL Connect string: mysql://trac#localhost:3306/trac (base exists, utf8, innoDB)
OK.
$ trac-admin /home/tracprojects/main2 deploy /var/www/html/
OK.
Second Step
Then I move cgi-bin/trac.wsgi to my /cgi-bin/ server's alias folder. (mod_wsgi working well. NOT as a daemon. tested on wsgi scripts).
Then I've grant permissions to Apache user for whole directories I've create earlier. And add access from apache config. (order-allow-deny).
But when I open my browser and go to url, I've got this error message:
Internal Server Error
TracError: IOError: [Errno 13] Permission denied: '/home/tracprojects/main2/VERSION'
What I do wrong?
Do you use SElinux (enabled by default)? With default SElinux I believe Apache can not access /home. You can check this by disabling SElinux temporarily ("setenforce 0" as root) and maybe restarting Apache. Also check /var/log/audit.log.
Check permissions of '/home/tracprojects' etc. Apache runs as special user and simply may not be able to read into directories, read files, or even write files.
You may be better off using mod_wsgi daemon mode and telling mod_wsgi to run the process as a different user who can access that location. Even if do this, the WSGI script file directory still at least needs to be readable to Apache user.