教程视频
主要特点

  • 开放源代码、跨平台应用
  • 支持多种网页编程语言
  • 模块化设计、运行稳定、良好的安全性

注意:使用yum安装的时候,是没有模块的,只有源代码包编译安装才有
image.png
LAMP:

  • L: Linux
  • A: Apache
  • M: Mysql
  • P: PHP

LNMP:

  • L: Linux
  • N: Nginx
  • M: Mysql
  • P: PHP

image.png
image.png
image.png

image.png

安装apache

  1. tar zxvf apr-1.6.2.tar.gz
  2. tar zxvf apr-util-1.6.0.tar.gz
  3. // 解压缩apache
  4. tar jxvf httpd-2.4.29.tar.bz2
  5. // 需要将解压缩后的apr和apr-util放入apache的srclib目录中,不然预编译的时候会报错
  6. mv apr-1.6.2 httpd-2.4.29/srclib/apr
  7. mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util
  8. yum -y install gcc gcc-c++ make pcre-devel expat-devel perl

image.png

  1. // 进入apache目录
  2. cd httpd-2.4.29
  3. // 进行预编译
  4. ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
  5. // 编译安装
  6. make && make install

image.png
image.png
image.png

  1. // 将apache主程序apachectl复制到/etc/init.d目录下并重命名为httpd,这是开机自启动会加载的目录
  2. cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
  1. vi /etc/init.d/httpd
  2. # chkconfig: 35 85 21 //35级别自动运行 第85个启动 第21个关闭 这些不懂没关系
  3. # description: Apache is a World Wide Web server

image.png

  1. chkconfig -- add httpd
  2. 这样就能通过systemctlservice命令管理了

image.png

image.png
image.png
image.png

  1. vi /usr/local/httpd/conf/httpd.conf
  2. ServerName 域名

image.png

  1. ln -s /usr/local/httpd/conf/httpd.conf /etc
  2. ln -s /usr/local/httpd/bin/* /usr/local/bin

image.png

  1. systemctl stop firewalld.service
  2. setenforce 0
  1. // 语法检测,下面两个命令都行
  2. httpd -t
  3. apachectl -t
  4. // 启动apache服务
  5. service httpd start
  6. // 查看是否启动成功
  7. netstat -anpt | grep 80

image.png
image.png
image.png

修改完配置之后需要重启服务
image.png
image.png
通过ip地址可以访问
image.png

image.png
image.png