源代碼前端
源代碼人類可以看懂的且未經處理的,可是計算機並不能識別的純文本文件。mysql
庫:librarylinux
庫是用於開發軟件的子程序集合。庫不是獨立程序,他們是向其餘程序提供服務的代碼。sql
庫連接庫連接是指把一個或多個庫包括到程序中。有兩形式種連接:靜態連接和動態連接,相應的,前者連接的庫叫作靜態庫後者的叫作動態庫。apache
autoconf和automakevim
autoconf是一個用於生成能夠自動地配置軟件源碼包,便於生成腳本。緩存
configure腳本:檢查編譯環境是否知足編譯須要,爲下一步的編譯作準備,你能夠經過在 configure 後加上參數來對安裝進行控制,定義當前程序編譯時啓動哪一個特×××或功能,以及安裝路徑等。結果:會根據Makefile.in文件生成Makefile文件,該文件帶來的好處就是自動化編譯服務器
automake是一個從Makefile.am文件自動生成Makefile.in的工具。用於結合configure腳本生成Makefile文件,該文件是make命令的配置文件app
GNU提供的這兩套工具來協助咱們自動產生 makefile文件,而且讓開發出來的軟件能夠像大多數源碼包那樣,只需"./configure", "make","make install" 就能夠把源程序安裝到系統中。
dom
yum:Yellowdog Update Modifier。
基於RPM包管理的前端軟件包管理器,可以從指定的服務器自動下載RPM包而且安裝,能夠自動處理依賴性關係,而且一次安裝全部依賴的軟件包,無須繁瑣地一次次下載、安裝。配置yum
編譯安裝的步驟:
1.拿到源代碼,並解壓到特定目錄下
#tar xf package-version.tar.{gz|bz2xz}
2.切換至源代碼目錄中
#cd package-version
3.執行configure腳本
#./configure
4.編譯
#make
5.安裝 make install
注意若是 在 make 過程當中出現 error ,你就要記下錯誤代碼(注意不單單是最後一 行),而後你能夠向開發者提交 bugreport(通常在 INSTALL 裏有提交地址),或者你的系統少了一些依賴庫等,這些須要本身仔細研究錯誤代碼。
configure腳本的通用功能:
編譯時咱們須要定義的配置:
1.指定安裝路徑:
--prefisx=/usr/local/package_name
--sysconfdir=/etc/package_name
2.指定啓用的特性或禁用的特性
--enabled-feature 啓用特性
例:--enabled-fpm
--disable-feature 禁用特性
例:--disable-socket
3.指定依賴的功能、程序或文件
--with-function 啓用某功能
--without-function 禁用某功能
不一樣的程序,其configure腳本的功能不一樣,要獲取幫助則使用:
./configure --help
在編譯安裝以前先安裝2個開發包組:
CentOS 5:「Development tools」和「Development Libraries」
CentOS 6:「Development tools」和「Server Platform Development」
編譯安裝httpd:
1.經過ftp下載源程序代碼發現lfpt並無安裝,安裝lftp工具
root@localhost ~]# yum install ftp ........ ........ Is thisok [y/N]: y Downloading Packages: ftp-0.17-53.el6.i686.rpm | 56kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : ftp-0.17-53.el6.i686 1/1 Verifying : ftp-0.17-53.el6.i686 1/1 Installed: ftp.i686 0:0.17-53.el6 Complete!2.
2.登陸ftp服務器下載httpd的源代碼至本地目錄下(能夠去開源的網站下載源代碼)
[root@localhost /]# lftp 172.16.0.1 lftp 172.16.0.1:~> cd pub/Sources/sources/httpd/ lftp 172.16.0.1:/pub/Sources/sources/httpd> ls -l -rwxr--r-- 1500 500 785724Mar 11 2012apr-1.4.6.tar.bz2 -rwxr--r-- 1500 500 992859Aug 08 2012apr-iconv-1.2.1.tar.bz2 -rwxr--r-- 1500 500 635000Mar 11 2012apr-util-1.4.1.tar.bz2 -rwxr--r-- 1500 500 693258Apr 11 2013apr-util-1.5.2.tar.bz2 -rwxr--r-- 1500 500 5524905Jul 25 2013httpd-2.2.25.tar.bz2 -rwxr--r-- 1500 500 4949897Aug 20 2013httpd-2.4.6.tar.bz2 -rwxr--r-- 1500 500 18739Mar 09 2012mod_bw-0.7.tgz lftp 172.16.0.1:/pub/Sources/sources/httpd> gethttpd-2.2.25.tar.bz2 5524905bytes transferred lftp 172.16.0.1:/pub/Sources/sources/httpd> bye
3.解壓源代碼當前目錄下
[root@localhost /]# tar xf httpd-2.2.25.tar.bz2 [root@localhost /]#
4.切換至源碼目錄中
[root@localhost /]# cd httpd-2.2.25 [root@localhost httpd-2.2.25]#
[root@localhost httpd-2.2.25]# ls ABOUT_APACHE configure.in LAYOUT os acinclude.m4 docs libhttpd.dep README Apache.dsw emacs-style libhttpd.dsp README.platforms build httpd.dep libhttpd.mak README-win32.txt BuildAll.dsp httpd.dsp LICENSE ROADMAP BuildBin.dsp httpd.mak Makefile.in server buildconf httpd.spec Makefile.win srclib CHANGES include modules support config.layout INSTALL NOTICE test configure InstallBin.dsp NWGNUmakefile VERSIONING
5.查看幫助文檔
./configure --help 或用cat命令打開README文件
6.執行configure腳本,檢查編譯環境是否知足需求
[root@localhost httpd-2.2.25]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so checking for chosen layout... Apache checking for working mkdir -p... yes checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu ........ ........ Configuring APR librarycreating modules/aaa/Makefile creating modules/arch/win32/Makefile creating modules/cache/Makefile creating modules/database/Makefile Platform: i686-pc-linux-gnu checking for working mkdir -p... yes APR Version: 1.4.8 ........ ........ creating modules/aaa/Makefile creating modules/arch/win32/Makefile creating modules/cache/Makefile creating modules/database/Makefile ........ ........ config.status: creating support/phf_abuse_log.cgi config.status: creating support/split-logfile config.status: creating build/rules.mk config.status: creating build/pkg/pkginfo config.status: creating build/config_vars.sh config.status: creating include/ap_config_auto.h config.status: executing default commands
7.使用make命令進行編譯(注意在此過程時是否出現ERROR)
[root@localhost httpd-2.2.25]# make Making all insrclib make[1]: Entering directory `/httpd-2.2.25/srclib' Making all inapr make[2]: Entering directory `/httpd-2.2.25/srclib/apr' ......... ......... -o httpd modules.lo buildmark.o -export-dynamicserver/libmain.la modules/aaa/libmod_authn_file.la modules/aaa/libmod_authn_default.la modules/aaa/libmod_authz_host.la modules/aaa/libmod_authz_groupfile.la modules/aaa/libmod_authz_user.la modules/aaa/libmod_authz_default.la modules/aaa/libmod_auth_basic.la modules/filters/libmod_include.la modules/filters/libmod_filter.la modules/loggers/libmod_log_config.la modules/metadata/libmod_env.la modules/metadata/libmod_setenvif.la modules/metadata/libmod_version.la modules/http/libmod_http.la modules/http/libmod_mime.la modules/generators/libmod_status.la modules/generators/libmod_autoindex.la modules/generators/libmod_asis.la modules/generators/libmod_cgi.la modules/mappers/libmod_negotiation.la modules/mappers/libmod_dir.la modules/mappers/libmod_actions.la modules/mappers/libmod_userdir.la modules/mappers/libmod_alias.la modules/mappers/libmod_so.la server/mpm/prefork/libprefork.la os/unix/libos.la -lm /httpd-2.2.25/srclib/pcre/libpcre.la /httpd-2.2.25/srclib/apr-util/libaprutil-1.la /httpd-2.2.25/srclib/apr-util/xml/expat/libexpat.la /httpd-2.2.25/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread make[1]: Leaving directory `/httpd-2.2.25' [root@localhost httpd-2.2.25]#
8.將編譯好的源程序進行安裝使用 make install
[root@localhost httpd-2.2.25]# make install Making install insrclib make[1]: Entering directory `/httpd-2.2.25/srclib' Making install inapr make[2]: Entering directory `/httpd-2.2.25/srclib/apr' make[3]: Entering directory `/httpd-2.2.25/srclib/apr' make[3]: Nothing to be done for`local-all'. make[3]: Leaving directory `/httpd-2.2.25/srclib/apr' /httpd-2.2.25/srclib/apr/build/mkdir.sh /usr/local/httpd/lib /usr/local/httpd/bin /usr/local/httpd/build \ /usr/local/httpd/lib/pkgconfig /usr/local/httpd/include mkdir /usr/local/httpd mkdir /usr/local/httpd/lib mkdir /usr/local/httpd/bin mkdir /usr/local/httpd/build mkdir /usr/local/httpd/lib/pkgconfig mkdir /usr/local/httpd/include ................ mkdir /usr/local/httpd/man/man1 mkdir /usr/local/httpd/man/man8 mkdir /usr/local/httpd/manual make[1]: Leaving directory `/httpd-2.2.25' [root@localhost httpd-2.2.25]#
9.查看安裝以後的文件
[root@localhost httpd-2.2.25]# ls /usr/local/httpd/ bin build cgi-bin error htdocs icons include lib logs man manual modules [root@localhost httpd-2.2.25]# ls /etc/httpd/ extra httpd.conf magic mime.types original
啓動和中止httpd服務:
[root@localhost ~]# service httpd start Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName [ OK ] [root@localhost ~]# service httpd stop Stopping httpd: [ OK ] [root@localhost ~]# service httpd start
服務安裝完成以後須要做以下操做
1.將二進制應用程序添加至環境變量中:編輯配置文件"/etc/profile.d/httpd.sh"
[root@localhost /]# vim /etc/profile.d/httpd.sh PATH=/usr/local/httpd/bin:$PATH export PATH
2.使系統重讀二進制文件(source /etc/profile.d/httpd.sh )
[root@localhost /]# . /etc/profile.d/httpd.sh [root@localhost /]#
3.頭文件輸出給系統:爲/usr/local/httpd/include建立符號連接
root@localhost /]# ln -s /usr/local/httpd/include /usr/include/httpd
4.庫文件輸出:編輯配置文件:/etc/ld.so.conf.d/httpd.conf
[root@localhost /]# vim /etc/ld.so.conf.d/httpd.conf /usr/local/httpd/lib
5.讓系統從新生成庫文件並緩存:使用ldconfid命令
[root@localhost /]# ldconfig -v | grep "^[^[:space:]]" /usr/lib/atlas: /usr/local/httpd/lib: /usr/lib/mysql: /usr/lib/qt-3.3/lib: /lib: /usr/lib: /lib/tls: (hwcap: 0x8000000000000000) /lib/i686: (hwcap: 0x0008000000000000) /usr/lib/sse2: (hwcap: 0x0000000004000000) /usr/lib/tls: (hwcap: 0x8000000000000000) /lib/i686/nosegneg: (hwcap: 0x0028000000000000)
6.導出man文件:在/etc/man.config中添加"MANPATH /usr/local/httpd/man"
[root@localhost /]# vim /etc/man.config # MANPATH /opt/*/man # MANPATH /usr/lib/*/man # MANPATH /usr/share/*/man # MANPATH /usr/kerberos/man MANPATH /usr/local/httpd/man
啓動httptd服務:
在沒用將/usr/local/httpd/bin加入含金變量中也可用/usr/local/httpd/bin/apachectl start啓動httpd服務
[root@localhost /]# netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 00.0.0.0:111 0.0.0.0:* LISTEN tcp 0 00.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 00.0.0.0:50711 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:6011 0.0.0.0:* LISTEN tcp 0 0:::111 :::* LISTEN tcp 0 0:::33363 :::* LISTEN tcp 0 0:::22 :::* LISTEN tcp 0 0::1:631 :::* LISTEN tcp 0 0::1:25 :::* LISTEN tcp 0 0::1:6010 :::* LISTEN tcp 0 0::1:6011 :::* LISTEN [root@localhost /]# apachectl start httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain forServerName httpd (pid 18929) already running [root@localhost /]# netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 00.0.0.0:111 0.0.0.0:* LISTEN tcp 0 00.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 00.0.0.0:50711 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:6010 0.0.0.0:* LISTEN tcp 0 0127.0.0.1:6011 0.0.0.0:* LISTEN tcp 0 0:::111 :::* LISTEN tcp 0 0:::80 :::* LISTEN tcp 0 0:::33363 :::* LISTEN