Archive

Posts Tagged ‘solaris’

How to automatically start Apache on Solaris 9 reboot/boot

July 6th, 2009

Here’s how you can have Apache automatically start on system reboot/boot on Solaris 9.

  1. become root user
  2. cd /etc/init.d
  3. ls -al to see if there is a file named “apache.”
  4. If not, create a file named “apache” with the following:
  5. #!/sbin/sh
    #
    # Copyright 2004 Sun Microsystems, Inc. All rights reserved.
    # Use subject to license terms.
    #
    #ident “@(#)apache.sh 1.3 04/07/18 SMI”

    APACHE_HOME=/usr/local/apache2
    CONF_FILE=/usr/local/apache2/conf/httpd.conf
    PIDFILE=/var/run/httpd.pid
    TOMCAT_CF=/var/apache/tomcat/conf/server.xml

    if [ ! -f ${CONF_FILE} ]; then
    exit 0
    fi

    # see if we need to start/stop tomcat also

    CF=`egrep ‘^[ \t]*include[ \t]*/etc/apache/tomcat.conf’ $CONF_FILE`
    if [ -n "$CF" -a -f $TOMCAT_CF ]; then
    TOMCAT=yes
    TC_USER=`egrep ‘^[ \t]*User[ \t]‘ $CONF_FILE | nawk ‘{print $2}’`
    else
    TOMCAT=no
    fi

    case “$1″ in
    start)
    /bin/rm -f ${PIDFILE}
    cmdtext=”starting”
    if [ "x$TOMCAT" != xno ]; then
    (CATALINA_HOME=${APACHE_HOME}/tomcat; export CATALINA_HOME; \
    CATALINA_BASE=/var/apache/tomcat; export CATALINA_BASE; \
    JAVA_HOME=/usr/java; export JAVA_HOME; \
    /bin/su $TC_USER -c \
    “$CATALINA_HOME/bin/startup.sh”) \
    >/dev/null 2>&1
    fi
    ;;
    restart)
    cmdtext=”restarting”
    ;;
    stop)
    cmdtext=”stopping”
    if [ "x$TOMCAT" != xno ]; then
    (CATALINA_HOME=${APACHE_HOME}/tomcat; export CATALINA_HOME; \
    CATALINA_BASE=/var/apache/tomcat; export CATALINA_BASE; \
    JAVA_HOME=/usr/java; export JAVA_HOME; \
    /bin/su $TC_USER -c \
    “$CATALINA_HOME/bin/shutdown.sh”) \
    >/dev/null 2>&1
    fi
    ;;
    *)
    echo “Usage: $0 {start|stop|restart}”
    exit 1
    ;;
    esac

    echo “httpd $cmdtext.”

    /bin/sh -c “${APACHE_HOME}/bin/apachectl $1″ >/dev/null 2>&1
    status=$?

    if [ $status != 0 ]; then
    echo “exit status $status”
    exit 1
    fi
    exit 0

  6. Make sure the APACHE_HOME and CONF_FILE have the correct paths.
  7. chmod 744 /etc/init.d/apache
  8. Test your script to make sure it works:
    ./apache start
  9. cd /etc/rc3.d
  10. See if the “S50apache” symbolic link exists in that directory. If not then create the symbolic link (make sure you are not going to overwrite anything)
    ln -s /etc/init.d/apache S50apache
  11. Reboot the system by typing:
    /usr/sbin/reboot

apache, linux/unix, migration, php, ssh, web server

Start Sun One Web Server 7 on boot (Solaris 9)

June 10th, 2009

During the Sun One Web Server install, there is an option to have the web server start on system boot or reboot. In the case that you did not select this option, but would like the web server to start on boot, here’s how you do it.

  1. su -
  2. cd /etc/init.d
  3. create a file named SunWebServer7, and add the following:
    #!/sbin/sh

    #start SunOneWebServer 7 on system restart and boot

    case “$1″ in
    start)
    /var/opt/SUNWwbsvr7/https-SERVERNAME.com/bin/startserv
    ;;
    stop)
    /var/opt/SUNWwbsvr7/https-SERVERNAME.com/bin/stopserv
    ;;
    restart)
    /var/opt/SUNWwbsvr7/https-SERVERNAME.com/bin/restartserv
    ;;
    *)
    echo $”usage: $0 {start|stop|restart}”
    exit 1
    esac

  4. replace SERVERNAME with the name of your server
  5. make sure SunWebServer7 has the same ownership and permissions as the other files in the /etc/init.d directory
  6. create symbolic links to this script in the /etc/rc*.d/ directories. For example:

    ln -s /etc/init.d/SunWebServer7 /etc/rc0.d/K99SunWebServer

linux/unix, web server , ,

how to shutdown a Solaris server

February 5th, 2009

Here’s how to shutdown a Solaris server:

  1. login as root
  2. at the command line, type “sync”
  3. type “sync” a second time
  4. now type /etc/telinit 0   (NOTE: 0 = shutdown, s = single user mode, 6 = reboot)
  5. you will eventually get to an ‘ok’ prompt

From here you can actually unplug the server. If you would like to start the server up again, just type “boot” at the “ok” prompt.

linux/unix , ,