<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

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 日日麻批免费40分钟日本的| 最新久久免费视频| 中文字幕无码不卡免费视频| 亚洲黄色在线电影| 中文字幕免费在线看线人| 亚洲毛片无码专区亚洲乱| 亚洲高清中文字幕免费| 中文字幕亚洲男人的天堂网络 | 四虎在线成人免费网站| 亚洲国产精品综合久久2007| 一个人看www在线高清免费看| 亚洲永久在线观看| 国产精品无码免费视频二三区 | 久久精品夜色噜噜亚洲A∨| 91av免费在线视频| 久久亚洲精品成人| 97性无码区免费| 亚洲国产精品无码久久| 久久精品国产亚洲AV不卡| 久久久久成人片免费观看蜜芽| 亚洲高清免费在线观看| 女人被男人桶得好爽免费视频| 鲁啊鲁在线视频免费播放| 久久精品国产69国产精品亚洲 | 又粗又硬又大又爽免费视频播放| 一级毛片一级毛片免费毛片| 亚洲精品国偷自产在线| 日本免费人成在线网站| 亚洲AV日韩AV一区二区三曲 | 国产亚洲精久久久久久无码77777 国产亚洲精品成人AA片新蒲金 | 性生大片视频免费观看一级| 亚洲精品V欧洲精品V日韩精品| 在线观看免费视频资源| 处破女第一次亚洲18分钟| 国产亚洲A∨片在线观看| 好男人www免费高清视频在线| 免费国产污网站在线观看不要卡| 亚洲福利视频一区| 国产禁女女网站免费看| 日本免费一区二区三区四区五六区| 中文字幕在线观看亚洲日韩|