亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索
博主信息
博文 291
粉絲 0
評論 0
訪問量 450597
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
apache編譯安裝
原創(chuàng)
1439人瀏覽過

鏡像下載、域名解析、時(shí)間同步請點(diǎn)擊 阿里云開源鏡像站

源碼包編譯實(shí)例

下面通過編譯安裝httpd來深入理解源碼包安裝(httpd-2.4.54)

下載編譯工具,httpd以及其兩個(gè)依賴包的源碼包

//源碼包建議到官方網(wǎng)站下載

  1. [root@lnh ~]# mkdir xbz
  2. [root@lnh ~]# cd xbz/
  3. [root@lnh xbz]# dnf -y install gcc gcc-c++ make wget
  4. [root@lnh xbz]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
  5. [root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
  6. [root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
  7. [root@lnh xbz]# ls
  8. apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz

安裝apr

  1. [root@lnh xbz]# ls
  2. apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
  3. [root@lnh xbz]# tar -xf apr-1.7.0.tar.gz
  4. [root@lnh xbz]# ls
  5. apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
  6. //將apr解壓到當(dāng)前目錄
  7. [root@lnh xbz]# cd apr-1.7.0/
  8. [root@lnh apr-1.7.0]# ls
  9. apr-config.in build-outputs.mk helpers misc strings
  10. apr.dep CHANGES include mmap support
  11. apr.dsp CMakeLists.txt libapr.dep network_io tables
  12. apr.dsw config.layout libapr.dsp NOTICE test
  13. apr.mak configure libapr.mak NWGNUmakefile threadproc
  14. apr.pc.in configure.in libapr.rc passwd time
  15. apr.spec docs LICENSE poll tools
  16. atomic dso locks random user
  17. build emacs-mode Makefile.in README
  18. build.conf encoding Makefile.win README.cmake
  19. buildconf file_io memory shmem
  20. //進(jìn)入這個(gè)源碼包可以看見里面被解壓出來的東西
  21. [root@lnh apr-1.7.0]# ./configure --prefix=/usr/local/src/apr
  22. ...
  23. configure: creating ./config.status
  24. config.status: creating Makefile
  25. config.status: creating include/apr.h
  26. config.status: creating build/apr_rules.mk
  27. config.status: creating build/pkg/pkginfo
  28. config.status: creating apr-1-config
  29. config.status: creating apr.pc
  30. config.status: creating test/Makefile
  31. config.status: creating test/internal/Makefile
  32. config.status: creating include/arch/unix/apr_private.h
  33. config.status: executing libtool commands
  34. rm: cannot remove 'libtoolT': No such file or directory
  35. config.status: executing default commands
  36. //生成Makefile
  37. 一般常用的有 --prefix=PREFIX 這個(gè)選項(xiàng)的意思是定義軟件包安裝到哪
  38. 建議,源碼包都是安裝在/opt/目錄下或者/usr/local/src目錄下面
  39. [root@lnh apr-1.7.0]# make
  40. ...
  41. gcc -E -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I./include -I/root/xbz/apr-1.7.0/include/arch/unix -I./include/arch/unix -I/root/xbz/apr-1.7.0/include/arch/unix -I/root/xbz/apr-1.7.0/include -I/root/xbz/apr-1.7.0/include/private -I/root/xbz/apr-1.7.0/include/private export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> apr.exp
  42. sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
  43. sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/src/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/src/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
  44. make[1]: Leaving directory '/root/xbz/apr-1.7.0'
  45. //編譯生成Makefile,此處雖然出現(xiàn)了make[1]: Leaving directory '/root/xbz/apr-1.7.0',但是沒關(guān)系可以繼續(xù)進(jìn)行下一步安裝
  46. [root@lnh apr-1.7.0]# make install
  47. ...
  48. /usr/bin/install -c -m 755 /root/xbz/apr-1.7.0/build/mkdir.sh /usr/local/src/apr/build-1
  49. for f in make_exports.awk make_var_export.awk; do \
  50. /usr/bin/install -c -m 644 /root/xbz/apr-1.7.0/build/${f} /usr/local/src/apr/build-1; \
  51. done
  52. /usr/bin/install -c -m 644 build/apr_rules.out /usr/local/src/apr/build-1/apr_rules.mk
  53. /usr/bin/install -c -m 755 apr-config.out /usr/local/src/apr/bin/apr-1-config
  54. //進(jìn)行安裝
  55. [root@lnh apr-1.7.0]# cd /usr/local/src/apr/
  56. [root@lnh apr]# ls
  57. bin build-1 include lib
  58. //進(jìn)入apr的路徑進(jìn)行查看,默認(rèn)情況下,系統(tǒng)搜索庫文件的路徑只有/lib,/usr/lib,我們需要進(jìn)行修改在/etc/ld.so.conf.d/中創(chuàng)建以.conf為后綴名的文件,而后把要增添的路徑直接寫至此文件中。此時(shí)庫文件增添的搜索路徑重啟后有效,若要使用增添的路徑立即生效則要使用ldconfig命令
  59. [root@lnh apr]# cd /etc/ld.so.conf.d/
  60. [root@lnh ld.so.conf.d]# echo /usr/local/src/apr/lib/ >apr.conf
  61. [root@lnh ld.so.conf.d]# cd -
  62. /usr/local/src/apr
  63. //切換到前一個(gè)工作目錄
  64. [root@lnh apr]# ldconfig
  65. //使命令生效
  66. [root@lnh apr]# ln -s /usr/local/src/apr/include/ /usr/include/apr
  67. [root@lnh apr]# ll /usr/include/apr
  68. lrwxrwxrwx. 1 root root 27 Jul 12 20:31 /usr/include/apr -> /usr/local/src/apr/include/
  69. //將頭文件軟鏈接到/usr/include目錄下

安裝apr-util

  1. [root@lnh xbz]# dnf -y install expat-devel libxml2-devel pcre-devel
  2. //需要先安裝這個(gè)依賴
  3. [root@lnh xbz]# ls
  4. apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
  5. [root@lnh xbz]# tar -xf apr-util-1.6.1.tar.gz
  6. [root@lnh xbz]# ls
  7. apr-1.7.0 apr-util-1.6.1 httpd-2.4.54.tar.gz
  8. apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
  9. //解壓到當(dāng)前目錄
  10. [root@lnh xbz]# cd apr-util-1.6.1/
  11. [root@lnh apr-util-1.6.1]# ls
  12. aprutil.dep CHANGES include NWGNUmakefile
  13. aprutil.dsp CMakeLists.txt ldap README
  14. aprutil.dsw config.layout libaprutil.dep README.cmake
  15. aprutil.mak configure libaprutil.dsp README.FREETDS
  16. apr-util.pc.in configure.in libaprutil.mak redis
  17. apr-util.spec crypto libaprutil.rc renames_pending
  18. apu-config.in dbd LICENSE strmatch
  19. buckets dbm Makefile.in test
  20. build docs Makefile.win uri
  21. build.conf encoding memcache xlate
  22. buildconf export_vars.sh.in misc xml
  23. build-outputs.mk hooks NOTICE
  24. //進(jìn)入源碼包查看被解壓出來的東西
  25. [root@lnh apr-util-1.6.1]# ./configure --prefix=/usr/local/src/apr-util --with-apr=/usr/local/src/apr
  26. ...
  27. configure: creating ./config.status
  28. config.status: creating Makefile
  29. config.status: creating export_vars.sh
  30. config.status: creating build/pkg/pkginfo
  31. config.status: creating apr-util.pc
  32. config.status: creating apu-1-config
  33. config.status: creating include/private/apu_select_dbm.h
  34. config.status: creating include/apr_ldap.h
  35. config.status: creating include/apu.h
  36. config.status: creating include/apu_want.h
  37. config.status: creating test/Makefile
  38. config.status: creating include/private/apu_config.h
  39. config.status: executing default commands
  40. //生成Makefile文件,需要伴隨著上一個(gè)指定的依賴
  41. [root@lnh apr-util-1.6.1]# make
  42. ...
  43. gcc -E -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/xbz/apr-util-1.6.1/include -I/root/xbz/apr-util-1.6.1/include/private -I/usr/local/src/apr/include/apr-1 exports.c | grep "ap_hack_" | sed -e 's/^.*[)]\(.*\);$/\1/' >> aprutil.exp
  44. gcc -E -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/xbz/apr-util-1.6.1/include -I/root/xbz/apr-util-1.6.1/include/private -I/usr/local/src/apr/include/apr-1 export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> aprutil.exp
  45. sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
  46. make[1]: Leaving directory '/root/xbz/apr-util-1.6.1'
  47. //編譯生成的Makefile文件,出現(xiàn)make[1]: Leaving directory '/root/xbz/apr-util-1.6.1'這個(gè)沒有關(guān)系可以繼續(xù)進(jìn)行下一步安裝
  48. [root@lnh apr-util-1.6.1]# make install
  49. ...
  50. See any operating system documentation about shared libraries for
  51. more information, such as the ld(1) and ld.so(8) manual pages.
  52. ----------------------------------------------------------------------
  53. /usr/bin/install -c -m 644 aprutil.exp /usr/local/src/apr-util/lib
  54. /usr/bin/install -c -m 755 apu-config.out /usr/local/src/apr-util/bin/apu-1-config
  55. //進(jìn)行安裝
  56. [root@lnh apr-util-1.6.1]# cd /usr/local/src/apr-util/
  57. [root@lnh apr-util]# ls
  58. bin include lib
  59. //切換到apr-util安裝目錄進(jìn)行查看,默認(rèn)情況下,系統(tǒng)搜索庫文件的路徑只有/lib,/usr/lib,我們需要進(jìn)行修改在/etc/ld.so.conf.d/中創(chuàng)建以.conf為后綴名的文件,而后把要增添的路徑直接寫至此文件中。此時(shí)庫文件增添的搜索路徑重啟后有效,若要使用增添的路徑立即生效則要使用ldconfig命令
  60. [root@lnh apr-util]# cd /etc/ld.so.conf.d/
  61. [root@lnh ld.so.conf.d]# echo /usr/local/src/apr-util/ >apr-util.conf
  62. [root@lnh ld.so.conf.d]# cd -
  63. /usr/local/src/apr-util
  64. //切換到上一個(gè)工作目錄
  65. [root@lnh apr-util]# ldconfig //使其生效
  66. [root@lnh apr-util]# ln -s /usr/local/src/apr-util/include/ /usr/include/apr-util
  67. [root@lnh apr-util]# ll /usr/include/apr-util
  68. lrwxrwxrwx. 1 root root 32 Jul 12 21:10 /usr/include/apr-util -> /usr/local/src/apr-util/include
  69. //將頭文件軟鏈接到/usr/include目錄下

安裝httpd

  1. [root@lnh xbz]# tar -xf httpd-2.4.54.tar.gz
  2. [root@lnh xbz]# ls
  3. apr-1.7.0 apr-util-1.6.1 httpd-2.4.54
  4. apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.54.tar.gz
  5. //解壓到當(dāng)前目錄
  6. [root@lnh xbz]# cd httpd-2.4.54/
  7. [root@lnh httpd-2.4.54]# ls
  8. ABOUT_APACHE CMakeLists.txt InstallBin.dsp README
  9. acinclude.m4 config.layout LAYOUT README.CHANGES
  10. Apache-apr2.dsw configure libhttpd.dep README.cmake
  11. Apache.dsw configure.in libhttpd.dsp README.platforms
  12. apache_probes.d docs libhttpd.mak ROADMAP
  13. ap.d emacs-style LICENSE server
  14. build httpd.dep Makefile.in srclib
  15. BuildAll.dsp httpd.dsp Makefile.win support
  16. BuildBin.dsp httpd.mak modules test
  17. buildconf httpd.spec NOTICE VERSIONING
  18. CHANGES include NWGNUmakefile
  19. changes-entries INSTALL os
  20. //查看被解壓出來的東西
  21. [root@lnh httpd-2.4.54]# ./configure --prefix=/usr/local/src/httpd --with-apr=/usr/local/src/apr --with-apr-util=/usr/local/src/apr-util
  22. ...
  23. config.status: creating build/config_vars.sh
  24. config.status: creating include/ap_config_auto.h
  25. config.status: executing default commands
  26. configure: summary of build options:
  27. Server Version: 2.4.54
  28. Install prefix: /usr/local/src/httpd
  29. C compiler: gcc
  30. CFLAGS: -g -O2 -pthread
  31. CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
  32. LDFLAGS:
  33. LIBS:
  34. C preprocessor: gcc -E
  35. //生成Makefile文件
  36. [root@lnh httpd-2.4.54]# make
  37. ...
  38. /usr/local/src/apr/build-1/libtool --silent --mode=link gcc -g -O2 -pthread -o mod_rewrite.la -rpath /usr/local/src/httpd/modules -module -avoid-version mod_rewrite.lo
  39. make[4]: Leaving directory '/root/xbz/httpd-2.4.54/modules/mappers'
  40. make[3]: Leaving directory '/root/xbz/httpd-2.4.54/modules/mappers'
  41. make[2]: Leaving directory '/root/xbz/httpd-2.4.54/modules'
  42. make[2]: Entering directory '/root/xbz/httpd-2.4.54/support'
  43. make[2]: Leaving directory '/root/xbz/httpd-2.4.54/support'
  44. make[1]: Leaving directory '/root/xbz/httpd-2.4.54'
  45. //編譯生成Makefile文件,出現(xiàn)的一些沒有讀取到的問題沒有關(guān)系,繼續(xù)進(jìn)行下一步
  46. [root@lnh httpd-2.4.54]# make install
  47. ...
  48. Installing man pages and online manual
  49. mkdir /usr/local/src/httpd/man
  50. mkdir /usr/local/src/httpd/man/man1
  51. mkdir /usr/local/src/httpd/man/man8
  52. mkdir /usr/local/src/httpd/manual
  53. make[1]: Leaving directory '/root/xbz/httpd-2.4.54'
  54. //進(jìn)行安裝
  55. [root@lnh httpd-2.4.54]# cd /usr/local/src/httpd/
  56. [root@lnh httpd]# ls
  57. bin cgi-bin error icons logs manual
  58. build conf htdocs include man modules
  59. //切換到httpd的安裝目錄進(jìn)行查看,默認(rèn)情況下,系統(tǒng)搜索庫文件的路徑只有/lib,/usr/lib
  60. [root@lnh httpd]# ln -s /usr/local/src/httpd/include/ /usr/include/httpd
  61. [root@lnh httpd]# ll /usr/include/httpd
  62. lrwxrwxrwx. 1 root root 29 Jul 12 21:23 /usr/include/httpd -> /usr/local/src/httpd/include/
  63. //將頭文件軟鏈接到/usr/include目錄下
  64. [root@lnh httpd]# echo "export PATH=$PATH:/usr/local/src/httpd/bin" > /etc/profile.d/httpd.sh
  65. [root@lnh httpd]# source /etc/profile.d/httpd.sh
  66. //配置httpd的全局環(huán)境變量,并生成效果
  67. [root@lnh httpd]# which httpd
  68. /usr/local/src/httpd/bin/httpd
  69. [root@lnh httpd]# vim /etc/man_db.conf
  70. MANDATORY_MANPATH /usr/man
  71. MANDATORY_MANPATH /usr/share/man
  72. MANDATORY_MANPATH /usr/local/share/man
  73. MANDATORY_MANPATH /usr/local/src/httpd/man
  74. //添加后面這一行
  75. [root@lnh ~]# httpd
  76. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe57:f6f5%ens33\. Set the 'ServerName' directive globally to suppress this message
  77. httpd (pid 35719) already running
  78. //啟動服務(wù)
  79. [root@lnh ~]# netstat -antp | grep httpd
  80. tcp6 0 0 :::80 :::* LISTEN 35719/httpd
  81. [root@lnh ~]# ss -antl
  82. State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
  83. LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
  84. LISTEN 0 128 *:80 *:*
  85. LISTEN 0 128 [::]:22 [::]:*
  86. //查看端口
  87. [root@lnh ~]# systemctl stop firewalld.service
  88. //關(guān)閉防火墻

服務(wù)80端口

file

將httpd服務(wù)加入systemd

  1. [root@lnh ~]# cd /usr/lib/systemd/system
  2. [root@lnh system]# cp sshd.service httpd.service
  3. [root@lnh system]# vim httpd.service
  4. [Unit]
  5. Description=httpd server daemon //服務(wù)
  6. After=network.target sshd-keygen.target
  7. [Service]
  8. Type=forking
  9. ExecStart=/usr/local/src/httpd/bin/httpd //服務(wù)安裝的地方 開啟
  10. ExecStop=/usr/local/src/httpd/bin/httpd -s stop //停止
  11. ExecReload=/bin/kill -HUP $MAINPID //重新加載并發(fā)出信號(對pid對組程序的進(jìn)程號)可留可刪
  12. [Install]
  13. WantedBy=multi-user.target
  14. [root@lnh system]# systemctl daemon-reload
  15. //重新加載一下并生效
  16. [root@lnh system]# systemctl status httpd.service
  17. httpd.service - httpd server daemon
  18. Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor >
  19. Active: inactive (dead)
  20. //查看一下是否有這個(gè)服務(wù)
  21. [root@lnh system]# ss -antl
  22. State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
  23. LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
  24. LISTEN 0 128 [::]:22 [::]:*
  25. //這里要確保之前的httpd這個(gè)80端口關(guān)了,此處沒有就是關(guān)了
  26. [root@lnh system]# systemctl enable --now httpd.service
  27. Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service /usr/lib/systemd/system/httpd.service.
  28. //表示設(shè)置開機(jī)自啟的同時(shí)候把它立刻啟動
  29. [root@lnh system]# systemctl status httpd.service
  30. httpd.service - httpd server daemon
  31. Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor p>
  32. Active: active (running) since Tue 2022-07-12 23:15:02 CST; 2min 11s ago
  33. Process: 36389 ExecStart=/usr/local/src/httpd/bin/httpd (code=exited, sta>
  34. Main PID: 36390 (httpd)
  35. Tasks: 82 (limit: 11205)
  36. Memory: 24.3M
  37. CGroup: /system.slice/httpd.service
  38. ├─36390 /usr/local/src/httpd/bin/httpd
  39. ├─36391 /usr/local/src/httpd/bin/httpd
  40. ├─36392 /usr/local/src/httpd/bin/httpd
  41. └─36393 /usr/local/src/httpd/bin/httpd
  42. Jul 12 23:15:02 lnh systemd[1]: Starting httpd server daemon...
  43. Jul 12 23:15:02 lnh httpd[36389]: AH00558: httpd: Could not reliably determ>
  44. Jul 12 23:15:02 lnh systemd[1]: Started httpd server daemon.
  45. //查看狀態(tài),發(fā)現(xiàn)啟動了并且也設(shè)置了開機(jī)自啟
  46. [root@lnh system]# ss -antl
  47. State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
  48. LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
  49. LISTEN 0 128 *:80 *:*
  50. LISTEN 0 128 [::]:22 [::]:*
  51. //查看80端口
  52. [root@lnh system]# systemctl disable httpd.service
  53. Removed /etc/systemd/system/multi-user.target.wants/httpd.service.
  54. //關(guān)閉開機(jī)自啟

file

源碼編譯報(bào)錯(cuò)信息處理

  1. checking for APR... no
  2. configure: error: APR not found. Please read the documentation.
  3. //解決方案
  4. [root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
  5. [root@lnh xbz]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
  6. 提前把這兩個(gè)依賴包安裝好才可以進(jìn)行生成Makefile文件
  7. 無法進(jìn)行生成兩個(gè)依賴包的Makefile文件
  8. //解決方案
  9. [root@lnh xbz]# dnf -y install gcc gcc-c++ make wget
  10. 提前下載編譯工具
  11. [root@lnh ~]# netstat -antp | grep httpd
  12. -bash: netstat: command not found
  13. //解決方案
  14. [root@lnh ~]# dnf provides netstat
  15. dnf -y install net-tools-2.0-0.52.20160912git.el8.x86_64
  16. //尋找需要的包并進(jìn)行下載

本文轉(zhuǎn)自:https://www.cnblogs.com/tushanbu/p/16473452.html

本博文版權(quán)歸博主所有,轉(zhuǎn)載請注明地址!如有侵權(quán)、違法,請聯(lián)系admin@php.cn舉報(bào)處理!
全部評論 文明上網(wǎng)理性發(fā)言,請遵守新聞評論服務(wù)協(xié)議
0條評論
作者最新博文
關(guān)于我們 免責(zé)申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!
關(guān)注服務(wù)號 技術(shù)交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時(shí)隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號

  • 登錄PHP中文網(wǎng),和優(yōu)秀的人一起學(xué)習(xí)!
    全站2000+教程免費(fèi)學(xué)