LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "Forbidden / You don't have permission to access /~user/index.html on this server." (https://www.linuxquestions.org/questions/linux-newbie-8/forbidden-you-dont-have-permission-to-access-%7Euser-index-html-on-this-server-595305/)

honglin_8 10-28-2007 04:34 PM

"Forbidden / You don't have permission to access /~user/index.html on this server."
 
Hi,

I am new to Apache and I received a "Forbidden / You don't have permission to access /~user/index.html on this server." error

The OP is Fedora 7
Apache is 2.2.6

Permissions of all directories and files are set to rwxr-xr-x leading from /home all the way to the files inside public_html.

I have modified the httpd.conf file to make sure it looks for the /~user/public_html directory.

I did not touch any other file or area.
If I "killall httpd" and run /usr/sbin/httpd, then the index.html under the /~user/public_html displays. That means that it seems workd for my purpose.

However, after I run "/etc/init.d/httpd restart", it displayed stopping httpd [ok] starting httpd [ok], but I will not be able to see my index.html file under the /~user/public_html

The system index.html (the testing page) always worked.

May you help me?

Thanks in advance.

Hong

jessica_lilly 10-28-2007 08:56 PM

are you running the user as root if u can acsess shell type:
su root

and then your root password

Wim Sturkenboom 10-28-2007 11:38 PM

As /etc/init.d/httpd restart does not work, and /usr/sbin/httpd does work, I suggest that you check the differences between the two ways you start. There might be a different config that is in use or something else.

honglin_8 10-29-2007 12:41 PM

Thanks for your reply
 
Quote:

Originally Posted by jessica_lilly (Post 2940381)
are you running the user as root if u can acsess shell type:
su root

and then your root password

What do you mean? I have a web page which should be accessed by everyone on the internet. With one way to initiate the httpd, it waoked, and the other way (which is the default way from the boot) it does not work. Yes, I am runnig as root.

honglin_8 10-29-2007 12:46 PM

More help needed. :)
 
Quote:

Originally Posted by Wim Sturkenboom (Post 2940471)
As /etc/init.d/httpd restart does not work, and /usr/sbin/httpd does work, I suggest that you check the differences between the two ways you start. There might be a different config that is in use or something else.


How can I check the difference between the two? One is binary file and the other is text file. I believe the text file calling for the binary file. It should make sense that doen't matter which one, it ended up calling the binary file which is the one it worked. However, the text file did something extra to cause it does not work. Maybe it set up too tight security. I do not understand all the things that the text file is checking. Anyone can explain to me? Here it the text file.

#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

# check for 1.3 configuration
check13 () {
CONFFILE=/etc/httpd/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
GONE="${GONE}AccessConfig|ResourceConfig)"
if LANG=C grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
echo
echo 1>&2 " Apache 1.3 configuration directives found"
echo 1>&2 " please read /usr/share/doc/httpd-2.2.6/migration.html"
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
LANG=$HTTPD_LANG daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}

# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
echo -n $"Stopping $prog: "
killproc -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
RETVAL=$?
fi
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac

exit $RETVAL

digen 10-29-2007 02:58 PM

Simple and best way to troubleshoot is to check the Apache error_log.

honglin_8 10-29-2007 04:24 PM

This is the unbeliveable thing ... But still have problems
 
I was not able to start httpd correctly using
/etc/init.d/httpd restart (which give me stopping [OK] and starting [OK]) All I did is taking out of the lines with # sign and it worked. I mean I can issue /etc/init.d/httpd to see my web now. So both /etc/init.d/httpd and /usr/sbin/httpd worked. However, when I reboot the machine, it doesn't work. What else is wrong???

Wim Sturkenboom 10-29-2007 11:28 PM

Answering your question about the difference between the binary and the script:

/usr/sbin/httpd is a binary (as you stated) and you don't pass any parameters
/etc/init.d/httpd is a script that can pass a number of variables and hence influences the behaviour of apache

I also don't understand everything in the script. One thing that is different when you use the script is the possible call of /etc/sysconfig/httpd. And the fact that you pass $OPTIONS when you start the program.

Regarding the 'new' problem:

Are you sure it is that the script that's called on boot? I think in Fedora it's a symlink in rcX.d (where X is the run level); maybe the symlink points to another file. I don't use Fedora so can not really advice.

syberguyy 10-30-2007 08:41 AM

This message is generally caused because either

* The underlying file system permissions do not allow the User/Group under which Apache is running to access the necessary files; or
* The Apache configuration has some access restrictions in place which forbid access to the files.

You can determine which case applies to your situation by checking the error log.

In the case where file system permission are at fault, remember that not only must the directory and files in question be readable, but also all parent directories must be at least searchable (i.e., chmod +x /directory/path) by the web server in order for the content to be accessible.


All times are GMT -5. The time now is 10:16 AM.