今天小編來跟大家做個練習,就是如何在Centos7下安裝httpd源碼包.
一:下載httpd最新版本的源碼包
[root@localhost ~]# rpm -qa |grep httpd //查詢系統上是否已安裝httpd包 httpd-tools-2.4.6-45.el7.centos.4.x86_64 httpd-2.4.6-45.el7.centos.4.x86_64 [root@localhost ~]# rpm -qai |grep httpd //查詢安裝過的httpd包信息 Name : httpd-tools Source RPM : httpd-2.4.6-45.el7.centos.4.src.rpm URL : http://httpd.apache.org/ The httpd-tools package contains tools which can be used with Name : httpd Source RPM : httpd-2.4.6-45.el7.centos.4.src.rpm URL : http://httpd.apache.org/ //小編這兩步就是為了找出httpd包下載地址
二:解壓源碼包
[root@localhost /app]# ls //小編把壓縮包放到了/app下 httpd-2.4.27.tar.bz2 [root@localhost /app]# tar -jxf httpd-2.4.27.tar.bz2 //這里-j來解壓后綴名為.tar.bz2的壓縮包 [root@localhost /app]# ls httpd-2.4.27 httpd-2.4.27.tar.bz2 //解壓完成后出現http-2.4.27目錄
三:安裝包組Development Tools
[root@localhost /app]# yum groupinstall Development Tools
四:查看INSTALL或者READEME
[root@localhost /app]# cd httpd-2.4.27/ //進入到解壓后的目錄下 [root@localhost /app/httpd-2.4.27]# ls ABOUT_APACHE BuildBin.dsp emacs-style LAYOUT NOTICE srclib acinclude.m4 buildconf httpd.dep libhttpd.dep NWGNUmakefile support Apache-apr2.dsw CHANGES httpd.dsp libhttpd.dsp os test Apache.dsw CMakeLists.txt httpd.mak libhttpd.mak README VERSIONING apache_probes.d config.layout httpd.spec LICENSE README.cmake ap.d configure include Makefile.in README.platforms build configure.in INSTALL Makefile.win ROADMAP BuildAll.dsp docs InstallBin.dsp modules server [root@localhost /app/httpd-2.4.27]# less INSTALL //下面小編截取部分內容
五:生成makefile文件
[root@localhost /app/httpd-2.4.27]# ./configure --prefix=/app/apache27 --sysconfdir=/etc/apache27 //這里configure是腳本文件,./configure執行它;照INSTALL里的說明,--prefix來指定安裝路徑於/app下,--sysconfdir來指定配置文件目錄
六:編譯並安裝
[root@localhost /app/httpd-2.4.27]# make && make install
七:啟動httpd服務
七:啟動httpd服務 [root@localhost /app/apache27]# /app/apache27/bin/apachectl start [root@localhost /app/apache27]# systemctl status firewalld.service //查看防火牆狀態 ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) [root@localhost /app/apache27]# netstat -ntl //查看網絡監聽情況 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::80 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN [root@localhost /app/apache27]# ps -aux |grep httpd //查看是否存在httpd服務 root 60242 0.0 0.1 74784 2336 ? Ss 15:57 0:00 /app/apache27/bin/httpd -k start daemon 60243 0.0 0.2 365832 4276 ? Sl 15:57 0:00 /app/apache27/bin/httpd -k start daemon 60244 0.0 0.2 431368 4876 ? Sl 15:57 0:00 /app/apache27/bin/httpd -k start daemon 60245 0.0 0.2 365832 4276 ? Sl 15:57 0:00 /app/apache27/bin/httpd -k start daemon 60335 0.0 0.2 365832 4280 ? Sl 15:57 0:00 /app/apache27/bin/httpd -k start root 60364 0.0 0.0 112648 964 pts/0 R+ 15:57 0:00 grep --color=auto httpd [root@localhost /app/apache27]# ls bin build cgi-bin error htdocs icons include logs man manual modules [root@localhost /app/apache27]# cd htdocs/ [root@localhost /app/apache27/htdocs]# ls index.html [root@localhost /app/apache27/htdocs]# vim index.html
八:設置PATH及man路徑
[root@localhost /app/apache27]# echo 'export PATH=$PATH:/app/apache27/bin/' > /etc/profile.d/apache27.sh [root@localhost /app/apache27]# cat /etc/profile.d/apache27.sh export PATH=$PATH:/app/apache27/bin/ [root@localhost /app]# vim /etc/man_db.conf
[root@localhost /app/apache27]# man apachectl
至此,Centos7下安裝httpd源碼包練習完成,請多多指教,小編在此等候大家的評論哦。