天天看點

centos7下面apache源碼安裝

centos7下面apache源碼安裝

簡介

安裝步驟

  1. apr/apr-util
    1. apr官網
    2. download
    3. apr-1.5.2.tar.gz
    4. apr-util-1.5.4.tar.gz
    5. 編譯
      cd /usr/local/src
      tar -zxvf apr-1.5.2.tar.gz
      cd apr-1.5.2
      ./configure --prefix=/usr/local/apr
      make && make install
      
      cd /usr/local/src
      tar -zxvf apr-util-1.5.4.gz
      cd apr-util-1.5.4
      ./configure \
      --prefix=/usr/local/apr-util \
      --with-apr=/usr/local/apr
      make && make install
                 
  2. pcre
    1. pcre官網
    2. pcre download
    3. pcre-8.40.tar.gz
    4. 編譯
      cd /usr/local/src
      tar -zxvf pcre-8.40.tar.gz
      cd pcre-8.40
      ./configure --prefix=/usr/local/pcre
      make && make install
                 
  3. other program
    yum -y install wget
    yum -y install gcc gcc-c++
    yum install openssl openssl-devel  -y
               
  4. httpd
    1. apache官網
    2. Compiling and Installing
    3. apache download
    4. httpd-2.4.9.tar.gz
    5. 編譯
      ./configure \
      --prefix=/usr/local/apache \
      --sysconfdir=/etc/httpd \
      --enable-so \
      --enable-ssl \
      --enable-cgi \
      --enable-rewrite \
      --with-zlib \
      --with-pcre=/usr/local/pcre \
      --with-apr=/usr/local/apr \
      --with-apr-util=/usr/local/apr-util \
      --enable-mods-shared=most \
      --enable-mpms-shared=all \
      --with-mpm=prefork
      make && make install
                 
    6. 添加服務
      1. 添加httpd服務
        cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
        vi /etc/rc.d/init.d/httpd   --在檔案開頭加上下面2句(注:第一行3個數字參數意義分别為:哪些Linux級别需要啟動httpd(3,4,5);啟動序号(85);關閉序号(15))
            chkconfig: 345 85 15
            description: Activates/Deactivates Apache Web Server
        
        chkconfig -–add httpd
                   
      2. 添加httpd服務
        vim /usr/lib/systemd/system/httpd.service
            [Unit]
            Description=The Apache HTTP Server
            After=network.target remote-fs.target nss-lookup.target
        
            [Service]
            Type=notify
            EnvironmentFile=/etc/sysconfig/httpd
            ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
            ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
            ExecStop=/bin/kill -WINCH ${MAINPID}
            # We want systemd to give httpd some time to finish gracefully, but still want
            # it to kill httpd after TimeoutStopSec if something went wrong during the
            # graceful stop. Normally, Systemd sends SIGTERM signal right after the
            # ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
            # httpd time to finish.
            KillSignal=SIGCONT
            PrivateTmp=true
        
            [Install]
            WantedBy=multi-user.target
        
            # /etc/systemd/system/httpd.service.d/nopt.conf
            [Service]
            PrivateTmp=false
        
        
        systemctl status httpd.sevice
        systemctl start httpd.sevice
        systemctl stop httpd.sevice
        systemctl restart httpd.sevice
        systemctl enable httpd.sevice
                   

問題

/etc/init.d/httpd: line 97: lynx: command not found
    yum install lynx -y


    curl: (7) Failed connect to localhost:80; Connection refused
    yum install curl -y
           

參考資料

繼續閱讀