1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務時間:8:30-17:00
      你可能遇到了下面的問題
      關閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      Centos中怎么編譯配置httpd-創(chuàng)新互聯(lián)

      這篇“Centos中怎么編譯配置httpd”文章的知識點大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“Centos中怎么編譯配置httpd”文章吧。

      創(chuàng)新互聯(lián)主要為客戶提供服務項目涵蓋了網(wǎng)頁視覺設計、VI標志設計、全網(wǎng)整合營銷推廣、網(wǎng)站程序開發(fā)、HTML5響應式重慶網(wǎng)站建設公司成都做手機網(wǎng)站、微商城、網(wǎng)站托管及成都網(wǎng)站維護、WEB系統(tǒng)開發(fā)、域名注冊、國內(nèi)外服務器租用、視頻、平面設計、SEO優(yōu)化排名。設計、前端、后端三個建站步驟的完善服務體系。一人跟蹤測試的建站服務標準。已經(jīng)為成都建筑動畫行業(yè)客戶提供了網(wǎng)站營銷服務。

      方法一 分別編譯法


      1、下載源碼并解壓縮

      我們可以使用yum info httpdyum info apr來查看這兩個服務的官網(wǎng),然后我們?nèi)ス倬W(wǎng)下載新的穩(wěn)定版本:

      Centos中怎么編譯配置httpd

      Centos中怎么編譯配置httpd

      下面附上官網(wǎng)地址:


      httpd官網(wǎng):


      apr官網(wǎng):


      我們可以去官網(wǎng)下載新的穩(wěn)定版本,這里,小編下載的是apr-1.6.2.tar.gz,apr-util-1.6.0.tar.gz,httpd-2.4.28.tar.bz2,接下來的實驗,就以小編下載的版本為示范,給大家演示如何安裝。


      我們使用rz命令,將我們下載好的源碼包上傳至我們的centos6虛擬機,我們可以查看一下:

      [root@centos6 temp]# ll
      total 8004
      -rw-r--r-- 1 root root 1071074 sep 29 12:27 apr-1.6.2.tar.gz
      -rw-r--r-- 1 root root 565507 sep 29 12:27 apr-util-1.6.0.tar.gz
      -rw-r--r-- 1 root root 6553163 oct 15 12:35 httpd-2.4.28.tar.bz2

      接下來就是解壓縮:

      tar xvf httpd-2.4.28.tar.bz2
      tar xvf apr-util-1.6.0.tar.gz
      tar xvf apr-1.6.2.tar.gz

      解壓縮以后,我們照例查看一下:

      [root@centos6 temp]# ls
      apr-1.6.2 apr-1.6.2.tar.gz apr-util-1.6.0 
      apr-util-1.6.0.tar.gz httpd-2.4.28 httpd-2.4.28.tar.bz2

      我們發(fā)現(xiàn),現(xiàn)在已經(jīng)有了三個文件夾,該步驟完成。

      2、安裝所依賴的包組

      在編譯安裝開始之前,我們要先把所依賴的包組安裝上,不然在接下來的編譯安裝過程中會出錯。


      安裝命令如下:

      yum groupinstall "development tools" -y
      yum install pcre-devel -y
      yum install openssl-devel -y
      yum install expat-devel -y

      安裝成功后,我們就可以對apr的分別編譯了。

      3、編譯安裝apr-1.6.2

      我們對apr-1.6.2進行編譯安裝,首先要保證我們所有的操作都是在該文件夾內(nèi)進行的!


      首先,我們進入目錄

      [root@centos6 temp]# cd apr-1.6.2/
      [root@centos6 apr-1.6.2]# ls
      apr-config.in cmakelists.txt libapr.mak poll
      apr.dep  config.layout libapr.rc random
      apr.dsp  configure license readme
      apr.dsw  configure.in locks  readme.cmake
      apr.mak  docs  makefile.in shmem
      apr.pc.in  dso  makefile.win strings
      apr.spec  emacs-mode memory  support
      atomic  encoding misc  tables
      build  file_io  mmap  test
      buildconf  helpers  network_io threadproc
      build.conf include  notice  time
      build-outputs.mk libapr.dep nwgnumakefile tools
      changes  libapr.dsp passwd  user

      然后我們對其進行編譯安裝即可:

      [root@centos6 apr-1.6.2]# ./configure --prefix=/app/apr
      [root@centos6 apr-1.6.2]# make && make install

      編譯的命令很簡單,只需要指定一個目錄,要記住這個目錄0.0,接下來我們還會用到。


      編譯安裝完成后,我們來查看一下/app目錄,看是不是已經(jīng)生成了apr這個文件夾:

      [root@centos6 apr-1.6.2]# ls /app/
      apr

      可以看到已經(jīng)有了這個文件夾,所以這一步驟我們完成。

      4、編譯安裝apr-util-1.6.0

      跟上一步驟很是相似,但是有一個需要注意的地方就是,編譯apr-util-1.6.0的時候,需要依賴apr-1.6.2包,所以還要跟上apr-1.6.2的目錄。下面我們就來說說具體操作。


      首先,我們還是也要進入該目錄下:

      [root@centos6 temp]# cd apr-util-1.6.0
      [root@centos6 apr-util-1.6.0]# ls
      aprutil.dep configure.in makefile.win
      aprutil.dsp crypto  memcache
      aprutil.dsw dbd  misc
      aprutil.mak dbm  notice
      apr-util.pc.in docs  nwgnumakefile
      apr-util.spec encoding  readme
      apu-config.in export_vars.sh.in readme.cmake
      buckets  hooks  readme.freetds
      build  include  redis
      buildconf  ldap  renames_pending
      build.conf libaprutil.dep strmatch
      build-outputs.mk libaprutil.dsp test
      changes  libaprutil.mak uri
      cmakelists.txt libaprutil.rc xlate
      config.layout license  xml
      configure  makefile.in

      接著,我們就可以對它進行編譯安裝了,注意,編譯時的代碼與剛剛略有不同,需要加上apr-1.6.2的目錄:

      [root@centos6 apr-util-1.6.0]# ./configure --prefix=/app/apr-util --with-apr=/app/apr/
      [root@centos6 apr-util-1.6.0]# make && make install

      編譯的命令很簡單,只需要指定一個目錄,要記住這個目錄0.0,接下來我們還會用到。


      編譯安裝完成后,我們來查看一下/app目錄,看是不是已經(jīng)生成了apr-util這個文件夾:

      [root@centos6 apr-1.6.2]# ls /app/
      apr apr-util

      可以看到已經(jīng)有了這個文件夾,所以這一步驟我們完成。

      5、編譯安裝httpd-2.4

      同樣的,首先我們要進入這個目錄:  

      [root@centos6 temp]# cd httpd-2.4.28/
      [root@centos6 httpd-2.4.28]# ls
      about_apache docs  makefile.win
      acinclude.m4 emacs-style modules
      apache-apr2.dsw httpd.dep notice
      apache.dsw httpd.dsp nwgnumakefile
      apache_probes.d httpd.mak os
      ap.d  httpd.spec readme
      build  include  readme.cmake
      buildall.dsp install  readme.platforms
      buildbin.dsp installbin.dsp roadmap
      buildconf layout  server
      changes  libhttpd.dep srclib
      cmakelists.txt libhttpd.dsp support
      config.layout libhttpd.mak test
      configure license  versioning
      configure.in makefile.in

      接著,我們就進行編譯安裝,編譯的命令有些長,大家寫的時候要注意不要少寫了東西,不然就會報錯報錯報錯!或者就像小編這樣,把代碼分行寫,但是一定要加\符號才可以諾。

      [root@centos6 httpd-2.4.28]#./configure --prefix=/app/httpd24 \
      > --enable-so \
      > --enable-ssl \
      > --enable-cgi \
      > --enable-rewrite \
      > --with-zlib \
      > --with-pcre \
      > --with-apr=/app/apr/ \
      > --with-apr-util=/app/apr-util/ \
      > --enable-modules=most \
      > --enable-mpms-shared=all \
      > --with-mpm=prefork
      [root@centos6 httpd-2.4.28]# make && make install

      至此,編譯安裝的步驟全部結(jié)束。我們可以來測試了

      6、測試并進行配置

      首先,我們先來查看一下,我們的80端口是否處于沒有開啟的狀態(tài):

      [root@centos6 ~]# ss -tnl
      state recv-q send-q local address:port peer address:port 
      listen 0 128   :::22   :::* 
      listen 0 128   *:22   *:* 
      listen 0 128  127.0.0.1:631   *:* 
      listen 0 128  ::1:631  :::* 
      listen 0 100  ::1:25   :::* 
      listen 0 100  127.0.0.1:25   *:*

      可以看出我們的80端口并未開啟,強烈建議大家一定要查看,如果我們之前的機器上裝過httpd服務,就把他卸載,至少至少也要停止服務,保證我們的80端口是關閉的狀態(tài),不然我們新安裝的2.4版本是啟動不起來的!


      接著,我們進入/app/httpd24/bin/這個目錄,把服務開啟一下:

      [root@localhost ~]# cd /app/httpd24/bin/
      [root@localhost bin]# ./apachectl start
      ah00558: httpd: could not reliably determine the server's fully qualified domain name, using localhost.localdomain. set the 'servername' directive globally to suppress this message

      現(xiàn)在,我們再來查看一下端口開啟情況:

      [root@localhost bin]# ss -tnl
      state recv-q send-q local address:port peer address:port 
      listen 0 128   :::80   :::* 
      listen 0 128   :::22   :::* 
      listen 0 128   *:22   *:* 
      listen 0 128  127.0.0.1:631   *:* 
      listen 0 128  ::1:631  :::* 
      listen 0 100  ::1:25   :::* 
      listen 0 100  127.0.0.1:25   *:*

      可以看出,我們的80端口已經(jīng)開啟,接著我們就可以用其他的機器來測試一下了:


      我們在centos7上使用curl命令來測試:

      [root@centos7 ~]# curl 192.168.191.128
      

      it works!

      測試成功。


      至此,我們的實驗已經(jīng)圓滿完成,已經(jīng)成功的在centos6上安裝上了httpd2.4版本。

      方法二 一次編譯法


      在上一個實驗中,我們使用分別編譯的方法把httpd2.4版本安裝到了centos6上,但是分別編譯的方法還是略有麻煩,那有沒有一次就可以完成編譯的方法呢?小編很負責任的告訴你,當然是有的!接下來我們就來看一看如何才能一次編譯安裝所有的東西~

      1、下載源碼并上傳至虛擬機

      我們可以使用yum info httpdyum info apr來查看這兩個服務的官網(wǎng),然后我們?nèi)ス倬W(wǎng)下載新的穩(wěn)定版本:

      Centos中怎么編譯配置httpd


      Centos中怎么編譯配置httpd

      下面附上官網(wǎng)地址:


      httpd官網(wǎng):


      apr官網(wǎng):


      我們可以去官網(wǎng)下載新的穩(wěn)定版本,這里,小編下載的是apr-1.6.2.tar.gz,apr-util-1.6.0.tar.gz,httpd-2.4.28.tar.bz2,接下來的實驗,就以小編下載的版本為示范,給大家演示如何安裝。


      我們使用rz命令,將我們下載好的源碼包上傳至我們的centos6虛擬機,我們可以查看一下:

      [root@centos6 temp]# ll
      total 8004
      -rw-r--r-- 1 root root 1071074 sep 29 12:27 apr-1.6.2.tar.gz
      -rw-r--r-- 1 root root 565507 sep 29 12:27 apr-util-1.6.0.tar.gz
      -rw-r--r-- 1 root root 6553163 oct 15 12:35 httpd-2.4.28.tar.bz2

      該步驟完成。

      2、安裝所依賴的包組

      在編譯安裝開始之前,我們要先把所依賴的包組安裝上,不然在接下來的編譯安裝過程中會出錯。


      安裝命令如下:

      yum groupinstall "development tools" -y
      yum install pcre-devel -y
      yum install openssl-devel -y
      yum install expat-devel -y

      安裝成功后,我們就可以對apr的分別編譯了。

      3、對源碼進行解壓縮

      第一步中,我們已經(jīng)把源碼上傳到了我們的虛擬機上,但是還沒有進行任何操作,這一步驟中,我們就需要把源碼進行解壓縮,并放入指定的文件夾中,來創(chuàng)造一次編譯安裝的條件,具體操作如下:


      首先,對三個包分別進行解壓:

      tar xvf httpd-2.4.28.tar.bz2
      tar xvf apr-util-1.6.0.tar.gz
      tar xvf apr-1.6.2.tar.gz

      解壓完成后,我們把xvf apr-1.6.2.tar.gz和apr-util-1.6.0.tar.gz分別復制到httpd-2.4.28.tar.bz2這個目錄下的指定文件夾中并改名字:

      [root@centos6 temp]# cp -a apr-1.6.2 httpd-2.4.28/srclib/apr
      [root@centos6 temp]# cp -a apr-util-1.6.0 httpd-2.4.28/srclib/apr-util
      [root@centos6 temp]# ls httpd-2.4.28/srclib/
      apr apr-util makefile.in

      我們可以看出,在httpd-2.4.28/srclib/目錄下已經(jīng)有了apr和apr-util這兩個文件夾了。本步驟完成。

      4、編譯安裝

      準備工作都做好了,接下來就是編譯安裝了。


      一樣的,需要先進入到httpd-2.4.28/這個目錄下。由于代碼很長,希望大家仔細仔細再仔細,或者像小編一樣分行寫:

      [root@centos6 temp]# cd httpd-2.4.28
      [root@centos6 httpd-2.4.28]# ./configure --prefix=/app/httpd24 \
      --enable-so \
      --enable-ssl \
      --enable-cgi \
      --enable-rewrite \
      --with-zlib \
      --with-pcre \
      --with-included-apr \
      --enable-modules=most \
      --enable-mpms-shared=all \
      --with-mpm=prefork
      [root@centos6 httpd-2.4.28]# make -j 4 && make install

      安裝的make -j 4 && make install這一行代碼意思是開啟4個進程同時工作,進行安裝,這樣速度比較快一些。


      以上,編譯安裝完成,接著,我們可以進行測試,并進行一些配置的修改。

      5、測試并進行配置

      首先,進入/app/httpd24這個文件夾,查看一下內(nèi)容:

      [root@centos6 httpd24]# ls
      bin build cgi-bin conf error htdocs icons include lib logs man manual modules 

      上一個實驗我們是進入bin/目錄下,然后使用apachectl來啟動我們的服務的,但是如果每次都這樣啟動服務,無疑很麻煩,因為要加上路徑,所以我們干脆把這個路徑設置到path變量里面,這樣我們使用服務就會變得比較方便,具體操作如下:

      [root@centos6 bin]# vim /etc/profile.d/httpd24.sh
      path=/app/httpd24/bin:$path

      然后我們運行一下使它生效:

      [root@centos6 bin]# . /etc/profile.d/httpd24.sh

      現(xiàn)在我們在任意頁面都可以啟動我們的服務。

      [root@centos6 bin]# apachectl start

      我們現(xiàn)在可以在另一臺機器上測試一下我們的服務:

      [root@centos7 ~]# curl 192.168.191.128
      

      it works!

      我們的頁面是保存在/app/httpd24/htdocs/這個文件夾里的,我們也可以根據(jù)自己的需要,把這個頁面修改一下~:

      [root@centos6 httpd24]# cd htdocs/
      [root@centos6 htdocs]# ls
      index.html
      [root@centos6 htdocs]# vim index.html 
      

      welcome to keer'home!

      然后我們再去centos7上查看一下:

      [root@centos7 ~]# curl 192.168.191.128
      

      welcome to keer'home!

      已經(jīng)是我們修改過后的樣子了。


      當然,我們還是希望能夠?qū)懗煞漳_本,這樣的話,我們使用起來就更加便利,現(xiàn)在我們的服務已經(jīng)啟動起來了,我們可以用ps aux來查看一下:

      [root@centos6 htdocs]# ps aux
      user  pid %cpu %mem vsz rss tty  stat start time command
      root   1 0.0 0.0 19348 1560 ?  ss 00:22 0:01 /sbin/init
      root   2 0.0 0.0  0  0 ?  s 00:22 0:00 [kthreadd]
      ……
      daemon 35258 0.0 0.0 76416 1436 ?  s 00:53 0:00 /app/httpd24/bin/httpd -k start
      daemon 35259 0.0 0.0 76416 1436 ?  s 00:53 0:00 /app/httpd24/bin/httpd -k start
      daemon 35260 0.0 0.1 76416 2104 ?  s 00:53 0:00 /app/httpd24/bin/httpd -k start
      daemon 35261 0.0 0.1 76416 2084 ?  s 00:53 0:00 /app/httpd24/bin/httpd -k start
      daemon 35262 0.0 0.1 76416 2084 ?  s 00:53 0:00 /app/httpd24/bin/httpd -k start
      daemon 35264 0.0 0.0 76416 1440 ?  s 00:54 0:00 /app/httpd24/bin/httpd -k start
      root  35326 13.0 0.0 110260 1152 pts/0 r+ 01:22 0:00 ps aux

      在這里我們又發(fā)現(xiàn)了一個問題,此時的httpd是以daemon的身份運行的,我們當然是希望它是由apache的身份來運行,所以我們可以來修改一下:


      我們先來查看一下apache這個用戶是否存在:

      [root@centos6 htdocs]# id apache
      uid=48(apache) gid=48(apache) groups=48(apache)

      如果不存在的話,我們可以使用useradd -r apache來創(chuàng)建,因為apache是系統(tǒng)的服務用的賬號,所以需要加上-r


      然后我們就可以來修改配置文件了,配置文件在/app/httpd24/conf/這個文件夾里,我們進去并把文件修改一下:

      [root@centos6 ~]# cd /app/httpd24/conf/
      [root@centos6 conf]# ls
      extra httpd.conf magic mime.types original
      [root@centos6 conf]# vim httpd.conf

      打開這個文件以后,我們把:

      user daemon
      group daemon

      改成這樣:

      user apache
      group apache

      這樣就可以了,我們現(xiàn)在把服務停止,重新打開,然后再用ps aux來查看一下:

      [root@centos6 conf]# apachectl stop
      [root@centos6 conf]# apachectl start
      [root@centos6 conf]# ps aux
      user  pid %cpu %mem vsz rss tty  stat start time command
      root   1 0.0 0.0 19348 1560 ?  ss 00:22 0:01 /sbin/init
      root   2 0.0 0.0  0  0 ?  s 00:22 0:00 [kthreadd]
      ……
      apache 35352 0.0 0.0 76416 1436 ?  s 01:33 0:00 /app/httpd24/bin/httpd -k start
      apache 35353 0.0 0.0 76416 1436 ?  s 01:33 0:00 /app/httpd24/bin/httpd -k start
      apache 35354 0.0 0.0 76416 1436 ?  s 01:33 0:00 /app/httpd24/bin/httpd -k start
      apache 35355 0.0 0.0 76416 1436 ?  s 01:33 0:00 /app/httpd24/bin/httpd -k start
      apache 35356 0.0 0.0 76416 1436 ?  s 01:33 0:00 /app/httpd24/bin/httpd -k start
      root  35357 3.0 0.0 110260 1152 pts/0 r+ 01:33 0:00 ps aux

      這樣,我們的httpd就是以apache的身份來運行的了。


      當然,我們還可以直接做成服務,服務腳本也不需要我們自己寫,直接把系統(tǒng)自帶的httpd的服務腳本復制一份,修改一下就可以了,具體操作步驟如下:

      [root@centos6 ~]# cd /etc/init.d
      [root@centos6 init.d]# ls
      abrt-ccpp   cpuspeed htcacheclean lvm2-monitor ntpd   rdma   spice-vdagentd   winbind
      abrtd    crond  httpd   mdmonitor  ntpdate  restorecond sshd     wpa_supplicant
      abrt-oops   cups  ip6tables  messagebus  portreserve rngd   svnserve
      acpid    dnsmasq iptables  netconsole  postfix  rsyslog  sysstat
      atd    firstboot irqbalance netfs   pppoe-server sandbox  udev-post
      auditd   functions kdump   network   psacct  saslauthd vmware-tools
      blk-availability haldaemon killall  networkmanager quota_nld  single  vmware-tools-thinprint
      bluetooth   halt  lvm2-lvmetad nfs-rdma  rdisc   smartd  wdaemon
      [root@centos6 init.d]# cp httpd httpd24
      [root@centos6 init.d]# vim httpd24

      文件里上面的內(nèi)容不需要改動,我們只需要修改一下路徑就可以了,也就是把

      # path to the apachectl script, server binary, and short-form for messages.
      apachectl=/usr/sbin/apachectl
      httpd=${httpd-/usr/sbin/httpd}
      prog=httpd
      pidfile=${pidfile-/var/run/httpd/httpd.pid}
      lockfile=${lockfile-/var/lock/subsys/httpd}
      retval=0
      stop_timeout=${stop_timeout-10}

      修改為:

      # path to the apachectl script, server binary, and short-form for messages.
      apachectl=/app/httpd24/bin/apachectl
      httpd=${httpd-/app/httpd24/bin/httpd}
      prog=httpd
      pidfile=${pidfile-/app/httpd24/logs/httpd.pid}
      lockfile=${lockfile-/var/lock/subsys/httpd24}
      retval=0
      stop_timeout=${stop_timeout-10}

      然后保存退出就可以了。


      接下來,就可以把這個服務添加到服務列表里了:

      [root@centos6 init.d]# chkconfig --add httpd24
      [root@centos6 init.d]# chkconfig httpd24 on
      [root@centos6 init.d]# chkconfig --list httpd24
      httpd24   0:off 1:off 2:on 3:on 4:on 5:on 6:off

      這樣,我們的httpd2.4版本就可以通過service來控制了。


      以上就是關于“Centos中怎么編譯配置httpd”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關的知識內(nèi)容,請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


      網(wǎng)站標題:Centos中怎么編譯配置httpd-創(chuàng)新互聯(lián)
      網(wǎng)頁地址:http://www.ef60e0e.cn/article/dgedej.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        辰溪县| 石泉县| 无棣县| 萨迦县| 台北市| 衡南县| 蓬安县| 昆山市| 柏乡县| 鞍山市| 图片| 明星| 湾仔区| 桃园县| 张掖市| 黄石市| 哈巴河县| 民权县| 炎陵县| 新河县| 龙游县| 葵青区| 西平县| 竹山县| 依安县| 思茅市| 泗阳县| 怀宁县| 高淳县| 呈贡县| 同德县| 禄劝| 时尚| 永春县| 拜泉县| 肇东市| 托克逊县| 尼木县| 黑山县| 二手房| 调兵山市|