yum安装

  1. yum install -y httpd
  2. #查看通过yum安装的mpm应用
  3. #启动
  4. systemctl start httpd
  5. #设置开机启动
  6. systemctl enable httpd
  7. #停止
  8. systemctl stop httpd
  9. httpd -l
  10. Compiled in modules:
  11. core.c
  12. mod_so.c
  13. http_core.c
  14. #yum安装默认应用eventMPM模块

源码编译安装

  1. #安装编译环境
  2. yum -y groupinstall "Development Tools"
  3. yum -y install openssl-devel pcre-devel expat-devel libtool
  4. #apr下载地址:http://apr.apache.org/
  5. wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
  6. wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
  7. #解压apr和apr-util包
  8. gzip -d apr-1.7.0.tar.gz
  9. gzip -d apr-util-1.6.1.tar.gz
  10. tar -xvf apr-1.7.0.tar
  11. tar -xvf apr-util-1.6.1.tar
  12. cd apr-1.7.0/
  13. ./configure --prefix=/usr/local/apr
  14. make&&make install
  15. cd apr-util-1.6.1/
  16. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  17. make&&make install
  18. gzip -d httpd-2.4.46.tar.gz
  19. tar -xvf httpd-2.4.46.tar
  20. cd httpd-2.4.46/
  21. ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
  22. make&&make install
  23. vim /etc/profile.d/httpd.sh
  24. export PATH=/usr/local/httpd/bin:$PATH
  25. source /etc/profile
  26. #测试httpd配置文件的正确性
  27. [root@localhost hehe]# httpd -t
  28. Syntax OK
  29. #启动httpd服务
  30. apachectl start