<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Linux 上服務的安裝以及示例:Apache服務的安裝(轉)

    1. chkconfig腳本格式:
    #!/bin/sh
    #chkconfig 2345 55 45
    #上面為固定格式:2345 表示運行級別,55表示開機執行順序,45為關機順序
    #description:this is just a demo of chkconfig script
    case “$1” in
    start)
    <start-script>
    ;;
    Stop)
    <stop-script>
    ;;
    Status)
    Echo <the information you want to display>
    ;;
    *)
    Echo “the usage of the script”
    Case
    2. 然后將腳本保存,并賦予執行權限,再復制到/etc/init.d目錄
    #chmod a+x <myscript>
    #copy <myscript> /etc/init.d
    3. 使用chkconfig命令添加成服務
    #chkconfig --add <myscript>
    #chkconfig --level 35 <myscript > on
    #chkconfig --list <myscript>
    4. 然后就可以通過service命令管理了
    #service <myscript> start | stop | status
    5. 下面是我寫的一個實例腳本,大家可以參考一些格式:
    #!/bin/sh
    #chkconfig: 2345 99 99
    #description:the script to set the network at run level 2345
    IN=eth0
    OUT=eth1
    HOST_NAME=cluster1.yang.com
    INIP=192.168.10.10
    OUTIP=192.168.136.10
    MASK=255.255.255.0
    IP=/sbin/ip
    IFC=/sbin/ifconfig
    ROUTE=/sbin/route
    #flush the address
    case "$1" in
    start)
    #echo "flush the address..."
    #$IP addr flush dev eth0
    #$IP addr flush dev eth1
    echo "set the address..."
    $IFC $IN $INIP netmask $MASK up
    $IFC $OUT $OUTIP netmask $MASK up
    echo "set the hostname..."
    hostname $HOST_NAME
    echo "set the default gateway..."
    $IP route flush all
    $ROUTE add default gw 192.168.136.2
    echo "finshed!!!"
    ;;
    stop)
    echo "flush the network setting..."
    $IP addr flush dev eth0
    $IP addr flush dev eth1
    echo "flush finshed!!!"
    ;;
    status)
    echo "hostname is $HOST_NAME"
    $IFC eth0
    $IFC eth1
    ;;
    *)
    echo "requires start,stop or status"
    ;;
    esac
    --------------------------------------------------------------------------------------------
    --------------------------------------------------------------------------------------------

    在Linux中chkconfighttpd任務添加,Apache服務器的最新穩定發布版本是httpd-2.2..0,官方下載地址是:http://httpd.apache.org/download.cgi。我們通過下面的步驟來快速的搭建一個web服務器。

    1、下載源碼文件httpd-2.2.0.tar.gz 到linux服務器的某個目錄。
    2、解壓文件 # tar zxvf httpd-2.2.0.tar.gz .
    3、配置 # ./configure –refix=/usr/local/apache //指定安裝目錄,以后要刪除安裝就只需刪除這個目錄。
    4、編譯和安裝。 # make ; make install .
    5、編寫啟動腳本,把它放到目錄 /etc/rc.d/init.d/里,這里取名為httpd,其內容如下:
     

    1. #!/bin/bash  
    2. #description:http server  
    3. #chkconfig: 235 98 98  
    4. case "$1" in  
    5. start)  
    6. echo "Starting Apache daemon..."  
    7. /usr/local/apache2/bin/apachectl -k start  
    8. ;;  
    9. stop)  
    10. echo "Stopping Apache daemon..."  
    11. /usr/local/apache2/bin/apachectl -k stop  
    12. ;;  
    13. restart)  
    14. echo "Restarting Apache daemon..."  
    15. /usr/local/apache2/bin/apachectl -k restart  
    16. ;;  
    17. status)  
    18. statusproc /usr/local/apache2/bin/httpd  
    19. ;;  
    20. *)  
    21. echo "Usage: $0 {start|stop|restart|status}"  
    22. exit 1  
    23. ;;  
    24. Esac  

     

    注意:#description:http server 這一行必須加上,否則在執行命令

     # chkconfig –add httpd

    時會出現“service apache does not support chkconfig”的錯誤報告。

    #chkconfig: 2345 98 98 表示在執行命令

     # chkconfig –add httpd 時會在目錄 /etc/rc2.d/ 、/etc/rc3.d/ /etc/rc5.d 分別生成文件 S98httpd和 K98httpd。這個數字可以是別的。

    6、執行命令 # chkconfig –add httpd ,進入目錄/etc/rc3.d/檢查是否生成文件 S98httpd及K98httpd.
    7、啟動服務 # service httpd start .



    Kyle Wang

    posted on 2013-01-17 10:23 王樹東 閱讀(500) 評論(0)  編輯  收藏 所屬分類: Environment SetupEnvironment Skills

    <2013年1月>
    303112345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    導航

    統計

    公告

    常用鏈接

    留言簿

    隨筆分類(17)

    隨筆檔案(15)

    文章分類(4)

    文章檔案(5)

    收藏夾(4)

    Algorithm

    Design

    Environment Setup

    Installer

    Maven

    MINA

    OS

    Skills for Java

    VIM

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲熟女乱综合一区二区| 一本无码人妻在中文字幕免费| 日本特黄a级高清免费大片| 亚洲宅男天堂a在线| 18禁免费无码无遮挡不卡网站| 亚洲一区中文字幕| 全免费毛片在线播放| 亚洲综合av一区二区三区| 在线观看视频免费国语| 亚洲a∨国产av综合av下载| 国产成人精品高清免费| 免费无码专区毛片高潮喷水| 中文字幕专区在线亚洲| 免费无码一区二区三区蜜桃| 亚洲日本在线看片| 久久久久久免费视频| 亚洲AV无码专区在线电影成人| 国产免费久久精品| 亚洲五月午夜免费在线视频| 亚洲理论电影在线观看| 亚洲一级毛片免费看| 亚洲日本VA午夜在线电影| 免费一级毛片免费播放| 中文字幕乱理片免费完整的| 久久亚洲春色中文字幕久久久| 成人免费毛片内射美女-百度| 色九月亚洲综合网| 亚洲av日韩av高潮潮喷无码| 无码免费午夜福利片在线 | 国产精品免费_区二区三区观看 | 日韩亚洲国产高清免费视频| 亚洲成a人无码亚洲成av无码 | 亚洲youwu永久无码精品| 亚洲AV无码乱码在线观看牲色| 久久久久久噜噜精品免费直播| 亚洲伊人久久大香线蕉影院| 免费欧洲美女牲交视频| 一级毛片全部免费播放| 亚洲AV成人精品日韩一区 | 亚洲国产精久久久久久久| 无码人妻精品一二三区免费|