LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to start apache+MySQL at system up? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-start-apache-mysql-at-system-up-2878/)

epic 05-28-2001 07:51 PM


I installed the apache-1.3.20 and MySQL-3.23.38 on my RedHat7.1 ,but When I modified rc.local in /etc/ec.d to this



code:
--------------------------------------------------------------------------------#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

if [ -f /etc/redhat-release ]; then
R=$(cat /etc/redhat-release)

arch=$(uname -m)
a="a"
case "_$arch" in
_a*) a="an";;
_i*) a="an";;
esac

NUMPROC=`egrep -c "^cpu[0-9]+" /proc/stat`
if [ "$NUMPROC" -gt "1" ]; then
SMP="$NUMPROC-processor "
if [ "$NUMPROC" = "8" -o "$NUMPROC" = "11" ]; then
a="an"
else
a="a"
fi
fi

# This will overwrite /etc/issue at every boot. So, make any changes you
# want to make to /etc/issue here or you will lose them when you reboot.
echo "" > /etc/issue
echo "$R" >> /etc/issue
echo "Kernel $(uname -r) on $a $SMP$(uname -m)" >> /etc/issue

cp -f /etc/issue /etc/issue.net
echo >> /etc/issue
fi
touch /var/lock/subsys/local

fi


/usr/local/mysql/share/mysql/mysql.server start &

fi
/usr/local/apache/bin/apachectl start &

fi
--------------------------------------------------------------------------------


but the apache and mySQL did not start.
please help me!

jharris 05-28-2001 07:57 PM

Looks to me like you have too many 'fi's in there... A fi closes an if. Just trying having your lines at the very end of the file. Also run it from the command line yourself and see what error(s) it gives you... Remember to call the correct shutdown somewhere for mysql too!!

Jamie...

epic 05-28-2001 08:02 PM

How to call the correct shutdown for MySQL?
 
OK,thank you!apache and mySQL is up,
but How to call the correct shutdown for MySQL?

jharris 05-28-2001 08:10 PM

Code:

mysqladmin -u root --password=somepassword shutdown
will work but it will mean putting a password in a script which isn't really a good idea if you have any interactive users on the machine. The better option is mentioned in the mysql manaual:

4.16.3 Starting and Stopping MySQL Automatically
The mysql.server script can be used to start or stop the server
by invoking it with start or stop arguments:
shell> mysql.server start
shell> mysql.server stop
mysql.server can be found in the `share/mysql' directory
under the MySQL installation directory or in the `support-files'
directory of the MySQL source tree.

HTH

Jamie...

unSpawn 05-29-2001 07:53 PM

its better to centralize startup scripts in /etc/rc.d/init.d and then link em to the runlevel cuz it then also will work in tksysv and other apps that manage daemons. rc.local wasnt really ment for this, its not flexible.

--cut below
Code:

#!/bin/sh
# make it easy... choose one name:
#APP=/usr/local/mysql/share/mysql/mysql.server
#APP=/usr/local/apache/bin/apachectl
. /etc/rc.d/init.d/functions
case "$1" in
 start)
        $APP start &
        echo $(basename $APP) started
        ;;
  stop)
        # functions sourced makes we can use
        killproc $APP
        echo $(basename $APP) stopped
        ;;
restart)
        # since syntaxes differ we just do
        $0 stop
        $0 start
      *)
        echo "$0 [start|stop|restart]"
esac

--cut above


cut & past em as /etc/rc.d/init.d/msql and /etc/rc.d/init.d/httpd, the only thing to enable is the corresponding "APP" line.

now automagically start in runlevel 3:
Code:

ln -s /etc/rc.d/init.d/msql /etc/rc.d/rc3.d/S90msql
and
Code:

ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S95httpd
plus stop on halt:
Code:

ln -s /etc/rc.d/init.d/msql /etc/rc.d/rc0.d/K10msql
one more
Code:

ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc0.d/K15httpd
even tho i write these with my eyes closed, warnings still valid:
*take care with script that u havent written ureself

anroy 09-04-2006 09:44 PM

Apache and MySQL at system startup - SUCCESS!!
 
This is not meant to be a how-to, but I am just sharing my experience of something going smoothly, in case it helps anyone.

I installed MySQL, Apache and PHP from source tarballs.

Until now I have been starting MySQL and Apache manually everyday. It is a real pain. I had no idea how to make them start automatically but spent most of today investigating how to do this.

This worked on both my Xandros and Ubuntu 6.06 systems.

=========================================
MySQL
=========================================

-----------------------------------------
References Used
-----------------------------------------
http://www.adobe.com/devnet/dreamwea...cles/lamp.html
http://dev.mysql.com/doc/refman/5.0/...tic-start.html
http://dev.mysql.com/doc/refman/5.0/...ql-server.html
http://www.debian-administration.org/articles/28

-----------------------------------------
Changed in /etc/my.cnf (MySQL site)
-----------------------------------------
[mysqld]
user=mysql

-----------------------------------------
Set startup item (Dreamweaver site)
-----------------------------------------
# sudo cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
# sudo update-rc.d mysql defaults

Results of the update-rc.d command were as follows:

Adding system startup for /etc/init.d/mysql ...
/etc/rc0.d/K20mysql -> ../init.d/mysql
/etc/rc1.d/K20mysql -> ../init.d/mysql
/etc/rc6.d/K20mysql -> ../init.d/mysql
/etc/rc2.d/S20mysql -> ../init.d/mysql
/etc/rc3.d/S20mysql -> ../init.d/mysql
/etc/rc4.d/S20mysql -> ../init.d/mysql
/etc/rc5.d/S20mysql -> ../init.d/mysql


=========================================
Apache
=========================================

-----------------------------------------
References Used
-----------------------------------------
http://www.adobe.com/devnet/dreamwea...cles/lamp.html

-----------------------------------------
Set startup item (Dreamweaver site)
-----------------------------------------
# sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apache
# sudo update-rc.d apache defaults

Results of the update-rc.d command were as follows:

Adding system startup for /etc/init.d/apache ...
/etc/rc0.d/K20apache -> ../init.d/apache
/etc/rc1.d/K20apache -> ../init.d/apache
/etc/rc6.d/K20apache -> ../init.d/apache
/etc/rc2.d/S20apache -> ../init.d/apache
/etc/rc3.d/S20apache -> ../init.d/apache
/etc/rc4.d/S20apache -> ../init.d/apache
/etc/rc5.d/S20apache -> ../init.d/apache


Also, for anyone struggling with installation / environment issues regarding LAMP (Linux/Apache/MySQL/PHP), this article at the Dreamweaver site, of all places, has to be one of the best resources I have found.
http://www.adobe.com/devnet/dreamwea...cles/lamp.html


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