Advertisement
nhanle

Bài 4: Cài Đặt Chương Trình Apache 2.4.41 Từ Mã Nguồn

Feb 29th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. Bài 4: Cài Đặt Chương Trình Apache 2.4.41 Từ Mã Nguồn
  2.  
  3. Mục Lục
  4. 1. Các bước chính quá trình cài đặt từ mã nguồn
  5. 2. Biên dịch Cài đặt Apache 2.4.41
  6. 3. Thiết lập scripts để khởi động dịch vụ cài đặt
  7.  
  8.  
  9. 1. Các bước chính quá trình cài đặt từ mã nguồn
  10.  
  11. - Download source chương trình
  12. - Giải nén và chuyển vào trong folder
  13. - Tạo file configure
  14. - Make
  15. - Make install
  16.  
  17. 2. Biên dịch Cài đặt Apache 2.4.41
  18.  
  19. - Link tham khảo quá trình cài đặt
  20.  
  21. http://httpd.apache.org/docs/current/install.html
  22.  
  23. - Cài đặt các thư viện cần thiết
  24.  
  25. [root@desktop ~]# dnf install gcc
  26. [root@desktop ~]# dnf install openssl-devel
  27. [root@desktop ~]# dnf install pcre-devel
  28. [root@desktop ~]# dnf install expat-devel
  29.  
  30. - Download apache server 2.4.41
  31.  
  32. [root@desktop ~]# wget mirrors.viethosting.com/apache//httpd/httpd-2.4.41.tar.gz
  33. [root@desktop ~]# tar xvf httpd-2.4.41.tar.gz
  34. [root@desktop ~]# cd httpd-2.4.41
  35. [root@desktop httpd-2.4.18]# ./configure --help
  36. [root@desktop httpd-2.4.18]# ./configure --enable-ssl --enable-so --enable-http2 --enable-proxy
  37. --enable-ssl : apache ho tro SSL
  38. --enable-so : cho phep ta load "apache module" trong khi server dang hoat dong thong qua Dynamic Shared Object ( DSO )
  39.  
  40. checking for chosen layout... Apache
  41. checking for working mkdir -p... yes
  42. checking for grep that handles long lines and -e... /bin/grep
  43. checking for egrep... /bin/grep -E
  44. checking build system type... i686-pc-linux-gnu
  45. checking host system type... i686-pc-linux-gnu
  46. checking target system type... i686-pc-linux-gnu
  47.  
  48. Configuring Apache Portable Runtime library ...
  49.  
  50. checking for APR... no
  51. configure: error: APR not found. Please read the documentation.
  52.  
  53.  
  54. - Download apr-1.7.0.tar.gz và apr-util-1.6.1.tar.gz va su dung tar extract
  55.  
  56. [root@desktop ~]# wget http://mirrors.viethosting.com/apache/apr/apr-1.7.0.tar.gz
  57. [root@desktop ~]# wget http://mirrors.viethosting.com/apache/apr/apr-util-1.6.1.tar.gz
  58.  
  59.  
  60. [root@desktop ~]# tar xvf apr-1.7.0.tar.gz
  61. [root@desktop ~]# tar xvf apr-util-1.6.1.tar.gz
  62.  
  63.  
  64. - Sau đó di chuyển folder "apr-1.7.0" và "apr-util-1.6.1" vào trong "/root/httpd-2.4.41/srclib" và lần lượt đổi tên thành "apr" và "apr-util"
  65.  
  66. [root@desktop ~]# mv apr-1.7.0 /root/httpd-2.4.41/srclib/apr
  67. [root@desktop ~]# mv apr-util-1.6.1 /root/httpd-2.4.41/srclib/apr-util
  68.  
  69. - Ta reconfigure lại apache 2.4.18 và install lại
  70.  
  71. [root@desktop httpd-2.4.18]# ./configure --enable-ssl --enable-so --enable-proxy --with-included-apr
  72. [root@desktop httpd-2.4.18]# make
  73. [root@desktop httpd-2.4.18]# make install
  74.  
  75.  
  76. - Thử nghiệm khởi động dịch vụ
  77.  
  78. [root@srv ~]# updatedb
  79. [root@server apache2]# locate httpd.conf
  80. [root@server conf]# vi httpd.conf
  81.  
  82. #dong 89
  83. ServerAdmin admin@vmware.lab
  84.  
  85. #dong 98
  86. ServerName server.vmware.lab:80
  87.  
  88. [root@srv ~]# vi /etc/hosts
  89.  
  90.  
  91. [root@srv bin]# locate apachectl
  92. /usr/sbin/apachectl
  93.  
  94. [root@server bin]# /usr/sbin/apachectl
  95. [root@server bin]# /usr/sbin/apachectl -k [ start | stop ]
  96.  
  97.  
  98. 3. Tạo Scripts để quản lý ứng dụng
  99.  
  100. - Sử dụng systemd để kiểm tra các dịch vụ ở trong máy
  101.  
  102. [root@desktop ~]# systemctl --type=service
  103.  
  104. - Tạo scripts để khởi động dịch vụ apache
  105.  
  106. [root@desktop ~]# vim /etc/systemd/system/httpd.service
  107.  
  108. [Unit]
  109. Description=The Apache HTTP Server
  110. After=network.target
  111.  
  112. [Service]
  113. Type=forking
  114. ExecStart=/usr/local/apache2/bin/apachectl -k start
  115. ExecReload=/usr/local/apache2/bin/apachectl -k graceful
  116. ExecStop=/usr/local/apache2/bin/apachectl -k graceful-stop
  117. PIDFile=/usr/local/apache2/logs/httpd.pid
  118. PrivateTmp=true
  119.  
  120. [Install]
  121. WantedBy=multi-user.target
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement