工具:
Development tools組包
httpd-2.2.9.tar.gz
links網站瀏覽工具
安裝apache之前需要安裝編譯需要的環境“Development tools”這個是編譯使用的必須的環境包,使用下面的命令可以安裝。
[root@CentOS6 ~]# yum groupinstall " Development tools"
下載httpd的源碼包,并將軟件包上傳到linux系統中,使用tar進行解壓縮。
ABOUT_APACHE config.layout InstallBin.dsp os acinclude.m4 configure LAYOUT README Apache.dsw configure.in libhttpd.dsp README.platforms apachenw.mcp.zip docs LICENSE ROADMAP build emacs-style Makefile.in server BuildAll.dsp httpd.dsp Makefile.win srclib BuildBin.dsp httpd.spec modules support buildconf include NOTICE test CHANGES INSTALL NWGNUmakefile VERSIONING
解壓縮后會生成一個相應的軟件包目錄,進入后可以看很多文件和目錄,包括也有可執行的文件,其中configure就是我們需要配置使用的執行文件,里面還有說明文檔可以查看軟件的介紹和使用幫助說明(README, INSTALL)。
使用configure進行配置需要執行“./configure”,可以使用“–help”命令查看后面可以使用的選項;不加任何選項也可,“–prefix”可以指定將軟件安裝到哪個目錄下,如果不加此選項,默認會安裝到“/usr/local/apache2”下面,其他選項可以現在使用,也可以后期要使用時再定制,這也就是使用源碼安裝的好處。如:模塊等等。
[root@CentOS6 httpd-2.2.9]# ./configure --prefix=/usr/local/httpd ...
配置完成之后會在當前目錄下面生成一些文件,其中包括Makefile文件,如果這一步順利沒問題的話就可以執行下一步了。
[root@CentOS6 httpd-2.2.9]# ls ABOUT_APACHE config.nice LAYOUT README acinclude.m4 config.status libhttpd.dsp README.platforms Apache.dsw configure LICENSE ROADMAP apachenw.mcp.zip configure.in Makefile server build docs Makefile.in srclib BuildAll.dsp emacs-style Makefile.win support BuildBin.dsp httpd.dsp modules test buildconf httpd.spec modules.c VERSIONING CHANGES include NOTICE config.layout INSTALL NWGNUmakefile config.log InstallBin.dsp os
使用“make”、“make install”命令分別對軟件進行編譯和安裝
[root@CentOS6 httpd-2.2.9]# make [root@CentOS6 httpd-2.2.9]# make install
安裝好以后,在配置的安裝目錄下面會產生很多文件,其中個bin下面存放apache的啟動文件,進入bin目錄中,執行“ ./apachectl start”既可以啟動apache服務,以便我們進行訪問,為了網站能夠每天持續運行,可以將啟動腳本文件鏈接到“/bin”目錄下,并添加為開機啟動。
[root@CentOS6 ~]# cd /usr/local/ [root@CentOS6 local]# ls bin games include lib64 sbin src etc httpd lib libexec share [root@CentOS6 local]# cd httpd/bin/ ab apxs envvars-std htpasswd rotatelogs apachectl checkgid htcacheclean httpd apr-1-config dbmmanage htdbm httxt2dbm apu-1-config envvars htdigest logresolve [root@CentOS6 bin]# ./apachectl start httpd: apr_sockaddr_info_get() failed for CentOS6.8 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
查看apache端口是否已打開,安裝網站瀏覽工具對其進行測試,如果服務顯示已打開不能進行訪問,可以是防火墻阻止了,可以將其關閉進行測試,但在生成環境中不建議關閉防火墻,。
[root@CentOS6 bin]# netstat -ant | grep 80 tcp 0 0 :::80 :::* LISTEN [root@CentOS6 bin]# iptables -F [root@CentOS6 bin]# yum install links [root@CentOS6 bin]# links 10.1.252.205
原創文章,作者:cyh5217,如若轉載,請注明出處:http://www.www58058.com/39441