LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Change of user and directory in Apache (https://www.linuxquestions.org/questions/linux-server-73/change-of-user-and-directory-in-apache-4175574926/)

chadianscot 03-15-2016 03:51 AM

Change of user and directory in Apache
 
So, I'm trying to change the default user and default doc directory in apache on my Raspberry PI. I've successfully changed the user and group in the /etc/apche2/envvars file, and with that change everything seems to still be fine. The user is a member of the www-data group if that helps. I've then created a new folder in the home/user/ directory, and pointed the /etc/apache2/sites-enabled/000-default.conf file at it. I've put an index.html file in the directory, but when I attempt to browse to the PI, I get a forbidden error. Anyone know what I'm missing? This is the output of ls -l:


Code:

drwxr-xr-x 2 chadianscot chadianscot    4096 Mar 14 15:14 htmldocs

The index.html file has the same permissions as the htmldocs folder.

cliffordw 03-15-2016 04:25 AM

Hi there, and welcome to LQ.

I don't have access to my Pi right now, but can try and offer general Apache help so long...

I assume "chadianscot" is the user you want to run the web server? Can you confirm that your change to the user and group worked, and the server is running as that user? You can do this by looking at the output from:

Code:

ps -ef|grep httpd
There should also be an Apache error log, usually in /var/log/apache2/error_log or /var/log/httpd/error_log. This should tell you what the problem is.

Good luck!

chadianscot 03-15-2016 05:10 AM

Hi, yes chadianscot is the user (and group). The output of the
Code:

ps -ef|grep httpd
is

Code:

chadian+  2911  2822  0 10:07 pts/0    00:00:00 grep --color=auto httpd
and the logs show:
Code:

client denied by server configuration: /home/chadianscot/htmldocs/

cliffordw 03-15-2016 05:36 AM

Hi again,

Which version of Apache is this?

Do you have any allow/deny directives in your /etc/apache2/sites-enabled/000-default.conf file?

chadianscot 03-15-2016 05:41 AM

My sites enabled file looks like this

Code:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /home/chadianscot/htmldocs

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

and my apache version is


Code:

Server version: Apache/2.4.10 (Raspbian)

cliffordw 03-15-2016 06:51 AM

Hi,

I think you're missing an access control directive for the VirtualHost. Adding this should do:

Code:

Require all granted

chadianscot 03-15-2016 06:58 AM

What file do I add that to?

bathory 03-15-2016 09:16 AM

Quote:

Originally Posted by chadianscot (Post 5515713)
What file do I add that to?

Add the following in the sites enabled file
Code:

<Directory /home/chadianscot/htmldocs>
Require all granted
</Directory>


chadianscot 03-15-2016 09:22 AM

That worked! Thanks so much! I think it's supposed to be

Code:

<Directory "/home/chadianscot/htmldocs">
        Require all granted
</Directory>

though, no?

bathory 03-15-2016 09:28 AM

Quote:

Originally Posted by chadianscot (Post 5515772)
That worked! Thanks so much! I think it's supposed to be

Code:

<Directory "/home/chadianscot/htmldocs">
        Require all granted
</Directory>

though, no?

Sorry it was a typo. I've already corrected it.
You may mark the thread SOLVED Fro "Thread Tools" on top of the page

Regards


All times are GMT -5. The time now is 08:04 AM.