Simon wrote:
It may be because you appear to be trying to run the script from your server's document root directory.
If it works, then probably it's as well to carry on the way it is now, but if memory serves the normal PHP handler shouldn't need any of that. CGI scripts need execute permission to invoke their interpreters, but the PHP interpreter is invoked by Apache so PHP scripts need only be readable. Although there are security advantages to segregating them like CGI scripts, PHP files were intended to live in the document space with the static content.
That said, I really don't know what was causing your problem before.
As for getting it to start automatically, are you sure it isn't already? Try `netstat -at` after a fresh boot to see if something is listening on 'www'. If not, look for directories called /etc/rc{n}.d, for various {n} being the runlevels your system will do. These contain symlinks to the scripts in /etc/init.d and determine which services are started/killed when entering/leaving different runlevels. Either the installer didn't put the links in, or it made them for the wrong runlevel. You can probably use `who -r` to check your current runlevel (or `runlevel` as root). Use update-rc.d to make the links in the proper formats: check its man-page for options you might want.
Hope that helps,
Matthew
On Sat, 2007-08-04 at 19:50 +0100, Matthew wrote:
Simon wrote: As for getting it to start automatically, are you sure it isn't already? Try `netstat -at` after a fresh boot to see if something is listening on 'www'.
root@wildebeest:~# netstat -at Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:2208 *:* LISTEN tcp 0 0 localhost:mysql *:* LISTEN tcp 0 0 *:2317 *:* LISTEN tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 localhost:2207 *:* LISTEN
If not, look for directories called /etc/rc{n}.d, for various {n} being the runlevels your system will do. These contain symlinks to the scripts in /etc/init.d and determine which services are started/killed when entering/leaving different runlevels.
Rather than clutter this email with this long printout I have put the output of ls -l /etc/rc* on the net as: www.suffolk-ancestor-genealogy-research.co.uk/alug/ls_of_etc_rc.txt if you would like to take a look.
I have also put the output of ls -l /etc/init.d as: www.suffolk-ancestor-genealogy-research.co.uk/alug/ls_of_initd.txt
Either the installer didn't put the links in, or it made them for the wrong runlevel. You can probably use `who -r` to check your current runlevel (or `runlevel` as root).
root@wildebeest:/# runlevel N 2 root@wildebeest:/# who -r run-level 2 2007-08-06 06:42 last=
So, if I understand you correctly Matthew, you are saying that "who -r" shows I am currently at "Run Level 2" so the start-up scripts that would have been run are in /etc/rc2.d.
If I do an ls -l of /etc/rc2.d I see the contents of: www.suffolk-ancestor-genealogy-research.co.uk/alug/ls_of_etc_rc2d.txt
Looking at this I can see an entry for apache2 but also, confusingly, entries for apache. As far as I am aware I only have apache2, not apache, on my system:
root@wildebeest:/# ls -l /etc/rc2.d/S91* lrwxrwxrwx 1 root root 16 2007-07-27 20:39 /etc/rc2.d/S91apache -> ../init.d/apache lrwxrwxrwx 1 root root 17 2007-07-27 20:55 /etc/rc2.d/S91apache2 -> ../init.d/apache2 lrwxrwxrwx 1 root root 21 2007-07-27 20:46 /etc/rc2.d/S91apache-perl -> ../init.d/apache-perl lrwxrwxrwx 1 root root 20 2007-07-27 20:43 /etc/rc2.d/S91apache-ssl -> ../init.d/apache-ssl
If I manually run /etc/init.d/apache2 nothing happens: www.suffolk-ancestor-genealogy-research.co.uk/alug/output_of_etc_initd_apache2.txt
If I look at the contents of /etc/init.d/apache2 I see: www.suffolk-ancestor-genealogy-research.co.uk/alug/etc_initd_apache2.txt
and notice that it says at the top:
# apache2 This init.d script is used to start apache2. # It basically just calls apache2ctl.
I therefore assume that this script should give the same result as running apache2ctl. This is not however the case because if I run apache2ctl manually then it does in fact start apache:
root@wildebeest:/# /usr/sbin/apache2ctl restart apache2: apr_sockaddr_info_get() failed for wildebeest apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName httpd not running, trying to start
And if I now do a netstat and ps I can see it has now started running: www.suffolk-ancestor-genealogy-research.co.uk/alug/ps_after_apache2ctl_restart.txt
root@wildebeest:/# netstat -at Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:2208 *:* LISTEN tcp 0 0 localhost:mysql *:* LISTEN tcp 0 0 *:2317 *:* LISTEN tcp 0 0 *:www *:* LISTEN tcp 0 0 localhost:ipp *:* LISTEN tcp 0 0 localhost:2207 *:* LISTEN
Use update-rc.d to make the links in the proper formats: check its man-page for options you might want.
I think, going through the hints that you have given me above, it seems to me that /etc/init.d/apache2 exists, and a link to it exists in /etc/rc2.d however this apache2 script is not behaving the same as running apache2ctl manually from the command line. Is there anyone on the ALUG list who could suggest some ways I can debug this default apache2 startup script to see why it is not behaving as it should?
Hope that helps,
Matthew
Yes Matthew, I think your reply has helped me understand better how Apache starts and has perhaps narrowed down my problem to the /etc/init.d/apache2 script. The problem now is trying to suss out why this script isn't behaving as expected; especially bearing in mind I haven't touched this script so it should be a virgin file put there during my Ubuntu installation.
Any suggestions would be appreciated.
Sagr.
<snippity class="lotsOfRandomDebugStuff" />
Hi,
What you might be wanting to look at is the file /etc/default/apache2...
The contents of that file on install, IIRC are:
--- Begin File --- # 0 = start on boot; 1 = don't start on boot NO_START=1 --- End File ---
Thus defaulting to not starting the apache2 server on boot (or, infact, ever from the init script). Change that to NO_START=0 and reboot and the world should be a good place. Probably.
Hope that helps,
On Mon, 2007-08-06 at 08:21 +0100, Brett Parker wrote:
What you might be wanting to look at is the file /etc/default/apache2...
root@wildebeest:/# cat /etc/default/apache2 # 0 = start on boot; 1 = don't start on boot NO_START=1 root@wildebeest:/#
The contents of that file on install, IIRC are:
--- Begin File --- # 0 = start on boot; 1 = don't start on boot NO_START=1 --- End File ---
Yes, that is what I have.
Thus defaulting to not starting the apache2 server on boot (or, infact, ever from the init script).
?????? Errrr... Does this mean that EVERY SINGLE PERSON who wants to use Apache will encounter the same problem as me????
I am confused. What is the reasoning behind deliberately stopping Apache from starting automatically after someone has taken the trouble to install it? I would have thought the default would be to set it run rather than block it.
Change that to NO_START=0 and reboot and the world should be a good place. Probably.
Yipeeeeeeeeeeeeeeeeeeeeeeeeeeeee!, I have just done that and my computer is now chugging away happily saying "Hello World" to the universe.
Hope that helps,
Yes Brett; like you suggested, it looks like all my hassle boiled down to that one line in /etc/default/apache2. I wonder if this just a bug with Ubuntu or if every single person with every variation of Linux going to hit this same problem too?
Thanks again Brett, Matthew, and indeed all the other ALUGers who have helped me get to the bottom of this problem during this past week.
Hello World at last!
Sagr.
On Mon, Aug 06, 2007 at 09:14:55AM +0100, sagr wrote:
On Mon, 2007-08-06 at 08:21 +0100, Brett Parker wrote:
What you might be wanting to look at is the file /etc/default/apache2...
root@wildebeest:/# cat /etc/default/apache2 # 0 = start on boot; 1 = don't start on boot NO_START=1 root@wildebeest:/#
The contents of that file on install, IIRC are:
--- Begin File --- # 0 = start on boot; 1 = don't start on boot NO_START=1 --- End File ---
Yes, that is what I have.
Thus defaulting to not starting the apache2 server on boot (or, infact, ever from the init script).
?????? Errrr... Does this mean that EVERY SINGLE PERSON who wants to use Apache will encounter the same problem as me????
No, just debian and ubuntu users.
I am confused. What is the reasoning behind deliberately stopping Apache from starting automatically after someone has taken the trouble to install it? I would have thought the default would be to set it run rather than block it.
Will explain at the end ;)
Change that to NO_START=0 and reboot and the world should be a good place. Probably.
Yipeeeeeeeeeeeeeeeeeeeeeeeeeeeee!, I have just done that and my computer is now chugging away happily saying "Hello World" to the universe.
Hoorah.
Hope that helps,
Yes Brett; like you suggested, it looks like all my hassle boiled down to that one line in /etc/default/apache2. I wonder if this just a bug with Ubuntu or if every single person with every variation of Linux going to hit this same problem too?
It's not a bug, it's by design, and will occur with any debian derivitive - at install time it tells you about that file (or it certainly used to)...
Anyways - the basic reasoning behind it goes like this: if it's the first time you've installed the program, then you probably haven't configured it yet - now, although the default config *may* be ok - it might not be. In case you didn't want to open up port 80 on your machine to the world just by installing *a* package, lets set it to default to not starting. Make it a configuration issue to actually start the server, and you're not immediately distributing something that could (in theory at least) be a potential security hole.
BSD has defaulted to not starting services for a *long* time (it does it in a far far more complicated and, IMO, crappy way), at least in debian and ubuntu some services have a /etc/default/<serviceprogram> file that stops the service from automatically starting on boot in a similar way to the apache2 file.
I'm actually looking forward to all services following this mantra - that way I can install things, then configure them, *THEN* start them... as apposed to the current (occasional) install -> stop -> configure -> start that I go through.
Cheers,
On Mon, Aug 06, 2007 at 10:05:08AM +0100, Brett Parker wrote:
On Mon, Aug 06, 2007 at 09:14:55AM +0100, sagr wrote:
On Mon, 2007-08-06 at 08:21 +0100, Brett Parker wrote:
What you might be wanting to look at is the file /etc/default/apache2...
root@wildebeest:/# cat /etc/default/apache2 # 0 = start on boot; 1 = don't start on boot NO_START=1 root@wildebeest:/#
The contents of that file on install, IIRC are:
--- Begin File --- # 0 = start on boot; 1 = don't start on boot NO_START=1 --- End File ---
Yes, that is what I have.
Thus defaulting to not starting the apache2 server on boot (or, infact, ever from the init script).
?????? Errrr... Does this mean that EVERY SINGLE PERSON who wants to use Apache will encounter the same problem as me????
No, just debian and ubuntu users.
And, after all that - I've just prodded the debian apache2 maintainer, and it appears that they're going back to having it start on install (it's apparently already that way in unstable). Damned hippy maintainers changing thier minds and not doing what I want them to... Grrrrr.
/me ponders starting a thread on debian-devel for networked services to all not automagically start on first install.
Cheers,