LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Mandriva (https://www.linuxquestions.org/questions/mandriva-30/)
-   -   I got apache going! (https://www.linuxquestions.org/questions/mandriva-30/i-got-apache-going-131809/)

asktoby 01-05-2004 04:32 PM

I got apache going!
 
Hi,

This post details the steps I went through to get apache working on my Mandrake 9.1 box. There's a few queries along the way but it's mainly to help other people.

Installed Mandy 9.1 (didn't choose apache as part of the install)
Downloaded the apache source
compiled the source using:
$ ./configure --prefix=/usr/local/apache2
$ make
$ make install
$ /usr/local/apache2/bin/apachectl start

The final line gave the error:
"httpd: Could not determine the server's fully qualified domain name, using..."

so I edited /usr/local/apache2/conf/httpd.conf, finding the line:
#ServerName www.example.com:80
and uncommented it, changing it to:
ServerName xx.xxx.xx.xxx:80 (IP munged for security)

This is the static IP of my router, witch is set to forward external TCP (not UDP) requests on port 80 to the static local network IP of my linux machine. I hope I did this correctly - I'm not 100% sure!

Then, running
apachectl start
gave the error:

[error] (13)Permission denied: could not open transfer log file /usr/local/apache2/logs/access_log.
Unable to open logs

I then su'd into root, and ran:
./apachectl start
from within /usr/local/apache2/bin

No errors, and
ps ax | grep apac
shows:
16824 ? S 0:00 /usr/local/apache2/bin/httpd -k start

So it seems to be running, but is it safe to run apache as root?

If I then go to my web browser, and type
http://xx.xxx.xx.xxx (IP munged for security)
into the address bar it thinks for a while and returns:

An error occured while loading http://xx.xxx.xx.xxx: (IP munged for security)
Timeout on server
Connection was to xx.xxx.xx.xxx at port 80 (IP munged for security)

So I am unsure what to do next... then Brainwave! I went into Mandrake Control Centre and added 80/TCP under the advanced settings of my firewall. Success! Going to http://xx.xxx.xx.xxx (IP munged for security) now brings up the Apache test page. I am so happy, I am so happy!

Now I'd like to have apache run automatically when I boot my computer. I got an email app called "korn" to load automatically on boot by adding a link (right-click, create new, link to application) to it in:
file:/home/toby/.kde/Autostart

I can't do the same for apache since it needs root privelages. Any advice?

Dewar 01-05-2004 05:07 PM

It is not at all safe to run apache as root.

The log problems you are having might be caused by a simple permissions problem. Check the /usr/local/apache2/logs/access_log file permissions. Is the owner the same user as apache should be (usualy nobody but there are a few others)

Finally, if worse comes to worse, give full 766 permissions to that log file. It's better than running apache as root at least.

-Dewar

asktoby 01-06-2004 02:11 AM

Damn, I'm away from my computer all day now - I hope no-one finds the box before this evening...

So if, when I get home, I go:

cdcd usr/local/apache2/logs
chown nobody access_log

I should be able to run apache as a user, rather than root?

hypexr 01-06-2004 09:27 AM

Muhaha, I've already discovered what xx.xxx.xx.xxx really is and am well on my way to massive damage. Just Joking! Anywayz,

Running the initial instance of apache as root is almost always regarded as okay. The child processes should come up, however, as a different user. Like nobody, ect... Running as root is necessary to access privileged ports (port 80). You can run it as a user and not use a privileged port (port 8080, ect...). If doing this then the child processes are locked into being the same user, which is not always a good thing.

Dewar 01-06-2004 10:06 AM

Hmm, That's different than what I heard, but it does make a lot of sense. *shrug* I guess you learn something everyday. Sorry about my alarming message then.

-Dewar

asktoby 01-07-2004 05:12 AM

So, it is safer to run apache as root than as a user...

If I want to run apache automatically at startup I would probably try by adding some lines to .profile or .bash_profile

However, I guess that would run apache as the currently logged in user. How should I go about running it, at startup, as root? I can't imagine it would be possible without storing my root password somewhere which is surely a security risk?

Or maybe I'm barking up the wrong tree, in the wrong forest... I've never edited .profile or .bash_profile so I'm very naïve.

hypexr 01-07-2004 05:56 PM

I've never used Mandrake so I don't know about their run level scripts, but on some distributions you can create a script that will run the /usr/local/apache2/bin/apachectl start command. Then you can make it executable and put it in your /etc/rc.d or /etc/init.d or wherever your initiation scripts go. This will now be executed automatically on boot or it you will need to add it to one of your configuration files. Or if Mandrake has software to control this stuff, then use it.
Don't put it in your .profile or anything like that. :)


All times are GMT -5. The time now is 09:58 PM.