Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old July 16th, 2002, 07:47 PM
JohnSaunders JohnSaunders is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 212 JohnSaunders User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 42 m 35 sec
Reputation Power: 7
Why Won't Apache and MySQL Start on Boot?

For some reason, Apache and MySQL won't start automatically when the server reboots. I am running Red Hat 7.2 with the latest versions of Apache and MySQL which are both installed in their default locations. I looked through the startup scripts for them and I believe everything is correct.

Can somebody tell me why it isn't working? They are both listed as a bootup action so the paths must be wrong somewhere.

This is what came up in the var/log/boot.log file:

Jul 16 11:24:35 mydomain httpd: bin startup failed
Jul 16 11:24:35 mydomain bin: execvp: Permission denied (What does this mean BTW)

Nothing was listed about MySQL in the file.

Here's a copy of my startup files:


Apache:

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

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

# This will prevent initlog from swallowing up a pass-phrase prompt.
INITLOG_ARGS=""

# Source additional OPTIONS if we have them.
if [ -f /etc/sysconfig/apache ] ; then
	. /etc/sysconfig/apache
fi

# Path to the httpd binary.
httpd=/usr/local/apache/bin
prog=httpd
RETVAL=0

# Change the major functions into functions.
moduleargs() {
	moduledir=/usr/lib/apache
	moduleargs=`
	/usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr '[:lower:]' '[:upper:]' | awk '{\
		gsub(/.*\//,"");\
		gsub(/^MOD_/,"");\
		gsub(/^LIB/,"");\
		gsub(/\.SO$/,"");\
		print "-DHAVE_" $0}'`
	echo ${moduleargs}
}
start() {
	echo -n $"Starting $prog: "
	daemon $httpd `moduleargs` $OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
	return $RETVAL
}
stop() {
	echo -n $"Stopping $prog: "
	killproc $httpd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status $httpd
	;;
  restart)
	stop
	start
	;;
  reload)
	echo -n $"Reloading $prog: "
	killproc $httpd -HUP
	RETVAL=$?
	echo
	;;
  condrestart)
	if [ -f /var/run/httpd.pid ] ; then
		stop
		start
	fi
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|reload|condrestart|status}"
	exit 1
esac

exit $RETVAL



MySQL

Code:
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind

# Mysql daemon start/stop script.

# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/S01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 90 90
# description: A very fast and reliable SQL database engine.

# The following variables are only set for letting mysql.server find things.
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf or other configuration files.

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

# Set some defaults
datadir=/usr/local/mysql/lib/mysql
basedir=/usr/local/mysql
pid_file=
if test -z "$basedir"
then
  basedir=/
  bindir=/usr/bin
else
  bindir="$basedir/bin"
fi
if test -z "$pid_file"
then
  pid_file=$datadir/`/bin/hostname`.pid
else
  case "$pid_file" in
    /* ) ;;
    * )  pid_file="$datadir/$pid_file" ;;
  esac
fi

mode=$1    # start or stop

parse_arguments() {
  for arg do
    case "$arg" in
      --basedir=*)  basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --datadir=*)  datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
    esac
  done
}

# Get arguments from the my.cnf file, groups [mysqld] and [mysql_server]
if test -x ./bin/my_print_defaults
then
  print_defaults="./bin/my_print_defaults"
elif test -x $bindir/my_print_defaults
then
  print_defaults="$bindir/my_print_defaults"
elif test -x $bindir/mysql_print_defaults
then
  print_defaults="$bindir/mysql_print_defaults"
else
  # Try to find basedir in /etc/my.cnf
  conf=/etc/my.cnf
  print_defaults=
  if test -r $conf
  then
    subpat='^[^=]*basedir[^=]*=\(.*\)$'
    dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
    for d in $dirs
    do
      d=`echo $d | sed -e 's/[ 	]//g'`
      if test -x "$d/bin/my_print_defaults"
      then
        print_defaults="$d/bin/my_print_defaults"
        break
      fi
      if test -x "$d/bin/mysql_print_defaults"
      then
        print_defaults="$d/bin/mysql_print_defaults"
        break
      fi
    done
  fi

  # Hope it's in the PATH ... but I doubt it
  test -z "$print_defaults" && print_defaults="my_print_defaults"
fi

parse_arguments `$print_defaults $defaults mysqld mysql_server`

# Safeguard (relative paths, core dumps..)
cd $basedir

case "$mode" in
  'start')
    # Start daemon

    if test -x $bindir/safe_mysqld
    then
      # Give extra arguments to mysqld with the my.cnf file. This script may
      # be overwritten at next upgrade.
      $bindir/safe_mysqld --datadir=$datadir --pid-file=$pid_file &
      # Make lock for RedHat / SuSE
      if test -w /var/lock/subsys
      then
        touch /var/lock/subsys/mysql
      fi
    else
      echo "Can't execute $bindir/safe_mysqld"
    fi
    ;;

  'stop')
    # Stop daemon. We use a signal here to avoid having to know the
    # root password.
    if test -f "$pid_file"
    then
      mysqld_pid=`cat $pid_file`
      echo "Killing mysqld with pid $mysqld_pid"
      kill $mysqld_pid
      # mysqld should remove the pid_file when it exits, so wait for it.

      sleep 1
      while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
      do
        [ -z "$flags" ] && echo "Wait for mysqld to exit\c" || echo ".\c"
        flags=a$flags
        sleep 1
      done
      if [ -s $pid_file ]
         then echo " gave up waiting!"
      elif [ -n "$flags" ]
         then echo " done"
      fi
      # delete lock for RedHat / SuSE
      if test -f /var/lock/subsys/mysql
      then
        rm /var/lock/subsys/mysql
      fi
    else
      echo "No mysqld pid file found. Looked for $pid_file."
    fi
    ;;

  *)
    # usage
    echo "usage: $0 start|stop"
    exit 1
    ;;
esac

Reply With Quote
  #2  
Old July 16th, 2002, 09:09 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,632 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 12 m 33 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
You've edited that apache startup script, haven't you? Why did you uncomment the lines
Code:
config: /usr/local/apache/conf/access.conf
config: /usr/local/apache/conf/httpd.conf
config: /usr/local/apache/conf/srm.conf


Just as a guess?

Comment them again, that's not valid syntax. Can you get your server to start when you use this script manually? What is the script's name, and where does it exist?

The path to your httpd binary is wrong, it needs to be the full path to executable, EG
Code:
httpd=/usr/local/apache/bin/httpd


I assume you installed apache from source, given that you're in /usr/local/apache. Have you tried using apachectl to start the httpd processes? Does it work?

Can you start up the daemons with these scripts when you use them manually?

I'm pretty good with setting up this type of stuff on linux- please let me know what you discover.

Reply With Quote
  #3  
Old July 16th, 2002, 10:25 PM
JohnSaunders JohnSaunders is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Posts: 212 JohnSaunders User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 42 m 35 sec
Reputation Power: 7
Hello Hero,

Thanks for your help! I was able to fix the Apache startup script with the changes you said to make and the MySQL server is starting up as well since I fixed the path.

Before I fixed it I just restarted the server then logged into Webmin and clicked the links to Start Apache and Start MySQL. At least now, I don't have to do it that way anymore.


My server only has 32 MBs of RAM and will maybe only receive about 50 - 100 visitors a day (in case that makes a difference). I have a few more questions that I was wondering if you could answer for me:

How will I know when I need to restart my server?

What is the difference between just restarting Apache/MySQL and the entire server?

How often should I restart Apache, MySQL, and the entire server (for each one)? Once a month? Once every 3 months?

John

Reply With Quote
  #4  
Old July 18th, 2002, 03:52 AM
enzo250gto's Avatar
enzo250gto enzo250gto is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: San Francisco, CA
Posts: 272 enzo250gto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Quote:
Originally posted by JohnSaunders

How will I know when I need to restart my server?

What is the difference between just restarting Apache/MySQL and the entire server?

How often should I restart Apache, MySQL, and the entire server (for each one)? Once a month? Once every 3 months?

John

Well I could be wrong on this but never. I've had my Linux Slackware machine up for over 200 days. Only reason I had to powerdown was to add memory. You will only need to restart the apache server if it goes down. Same with MySQL. Now that I re-read your post, the answer is like this. You will never need to restart the whole server. Its not bad for it but there is no need to. The difference in restarting the whole server versus the other two is obvious. If you restart the entire server it does the same as restarting apache and MySQL so you gain nothing by doing it this way ove r just restarting MySQL. Restarting the whole thing will just make it go through all its boot up, ftp, httpd, send mail, etc Last thing I'll say is, its Linux dude not a Dell w/ windows so you won't need to restart.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Why Won't Apache and MySQL Start on Boot?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway