LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-15-2016, 03:51 AM   #1
chadianscot
LQ Newbie
 
Registered: Mar 2016
Posts: 5

Rep: Reputation: Disabled
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.

Last edited by chadianscot; 03-15-2016 at 06:28 AM.
 
Old 03-15-2016, 04:25 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
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!
 
Old 03-15-2016, 05:10 AM   #3
chadianscot
LQ Newbie
 
Registered: Mar 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
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/

Last edited by chadianscot; 03-15-2016 at 05:34 AM.
 
Old 03-15-2016, 05:36 AM   #4
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
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?
 
Old 03-15-2016, 05:41 AM   #5
chadianscot
LQ Newbie
 
Registered: Mar 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
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)
 
Old 03-15-2016, 06:51 AM   #6
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi,

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

Code:
Require all granted
 
Old 03-15-2016, 06:58 AM   #7
chadianscot
LQ Newbie
 
Registered: Mar 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
What file do I add that to?
 
Old 03-15-2016, 09:16 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by chadianscot View Post
What file do I add that to?
Add the following in the sites enabled file
Code:
<Directory /home/chadianscot/htmldocs>
Require all granted
</Directory>

Last edited by bathory; 03-15-2016 at 09:29 AM. Reason: typo
 
Old 03-15-2016, 09:22 AM   #9
chadianscot
LQ Newbie
 
Registered: Mar 2016
Posts: 5

Original Poster
Rep: Reputation: Disabled
That worked! Thanks so much! I think it's supposed to be

Code:
<Directory "/home/chadianscot/htmldocs">
        Require all granted
</Directory>
though, no?
 
Old 03-15-2016, 09:28 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by chadianscot View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot change directory from ftp user shipon_97 Linux - Newbie 1 08-24-2009 02:33 AM
Apache Home Directory change not registering DavidSingleton Linux - Newbie 9 01-02-2009 11:28 AM
apache directory change luciusl Linux - Server 1 03-02-2007 06:10 AM
How Do I Change The Default Directory For Apache? Tear Syden Linux - Newbie 4 03-21-2006 10:16 PM
Letting normal user change apache directory nivek7 Linux - General 9 05-04-2004 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration