一、Apache简介
• 主要特点
– 开放源代码、跨平台应用
– 支持多种网页编程语言
– 模块化设计 、运行稳定、良好的安全性
• 软件版本
– 1.X
• 目前最高版本是1.3,运行稳定
• 向下兼容性较好,但缺乏一些较新的功能
– 2.X
• 目前最高版本是2.4
• 具有更多的功能特性
• 与1.X相比,配置管理风格存在较大差异
部署安装apache
注:一定关闭SELINUX及iptables防火墙

lamp架构:linux,apache,mysql,php

Apache:3000人,更大的并发量:使用负载均衡功能LB,如:LVS,HAPROXY,NGINX。

http://×××w.apache.org

发布静态网站的。
应用量高,跨平台应用,不收费,支持多种编程语言,模块化设计运行稳定

相对比的是nginx:10000人,兼容性和稳定性差一些。
可通过rpm或yum
rpm -ivh httpd-2.4.6-80.el7.centos.1.x86_64
yum install httpd –y

systemctl start httpd
systemctl enable httpd

APACHE配置文件选项

服务目录 /etc/httpd
主配置文件 /etc/httpd/conf/httpd.conf
网站数据目录 /var/×××w/html
访问日志 /var/log/httpd/access_log
错误日志 /var/log/httpd/error_log

默认主页文件存放目录(默认站点路径)为
/var/×××w/html/
vi index.html

日志文件存放路径为
/var/log/httpd/

主配置文件为
/etc/httpd/conf/httpd.conf
基本内容:

ServerRoot “/etc/httpd” 服务主目录
Listen 80 监听端口
User apache 启动用户
Group apache 启动组
ServerAdmin root@localhost 管理员邮箱
ServerName ×××w.wang.com 域名主机名
DocumentRoot “/var/×××w/html“ 默认主页存放目录
DirectoryIndex index.html 引所文件(设置主页)
ErrorLog logs/error_log 错误日志
CustomLog logs/access_log combined 访问日志

– CustomLog:访问日志文件的位置
– PidFile:保存httpd进程PID号的文件
– AddDefaultCharset:设置站点中的网页默认使用的字符集编码
– Timeout:网络连接超时,默认为300秒
– KeepAlive:是否保持连接,可选On或Off
– MaxKeepAliveRequests:每次连接最多请求文件数
– KeepAliveTimeout:保持连接状态时的超时时间
– Include:需要包含进来的其他配置文件
httpd服务的访问控制
– 作用
– 控制对网站资源的访问
– 为特定的网站目录添加访问授权
– 常用访问控制方式
– 客户机地址限制
– 用户授权限制
使用Require配置项实现访问控制,按先后顺序限制
可用于配置段中
Require配置项的常见语法

Require all granted
Require all denied
Require local
Require [not] host <主机名或域名列表>
Require [not] ip
使用not禁止访问时要将其置于 容器中并在容器中指定相应的限制策略

虚拟web主机的概念
在同一台服务器上建立多个web站点,每一个站点不独立占用一台真正的服务器

虚拟主机的分类
1.基于域名的虚拟主机 生产环境常用
2.基于IP的虚拟主机 基本不用
3.基于端口的虚拟主机 一般测试环境,Listen:8080
---------------------------------------下面是基于域名VHOST-----------------------------------------------------
NameVirtualHost 172.18.199.63:80 #这个配置项在新APACHE版本中可以省略

ServerAdmin [email protected]
DocumentRoot /var/×××w/aa
ServerName ×××w.aa.com
ErrorLog logs/aa-error_log
CustomLog logs/aa-access_log common


ServerAdmin [email protected]
DocumentRoot /var/×××w/bb
ServerName ×××w.bb.com
ErrorLog logs/bb-error_log
CustomLog logs/bb-access_log common

---------------------------------------------下面是基于端口vhost---------------------------------------------------------
Listen 8081
Listen 8082

ServerAdmin [email protected]
DocumentRoot /var/×××w/cc
ServerName ×××w.wang.com
ErrorLog logs/cc-error_log
CustomLog logs/cc-access_log common


ServerAdmin [email protected]
DocumentRoot /var/×××w/dd
ServerName ×××w.wang.com
ErrorLog logs/dd-error_log
CustomLog logs/dd-access_log common

-----------------------------下面是基于IP VHOST----------------------------------------------


ServerAdmin [email protected]
DocumentRoot /var/×××w/ee
ServerName ×××w.wang.com
ErrorLog logs/ee-error_log
CustomLog logs/ee-access_log common


ServerAdmin [email protected]
DocumentRoot /var/×××w/ff
ServerName ×××w.wang.com
ErrorLog logs/ff-error_log
CustomLog logs/ff-access_log common

二、LAMP及DISCUZ论坛
1、lamp介绍
LAMP:linux apache mariadb php

Yum remove httpd
Yum install httpd php php-mysql mariadb-server mariadb php-mbstring -y

开启apache、mysql服务
systemctl start httpd , systemctl start mariadb
开机启动httpd和mariadb服务
systemctl enable httpd , systemctl enable mariadb

输入命令mysql
mysql>show databases;
mysql> grant all privileges on *.* to bbsadmin@'localhost' identified by '123456';
im /etc/php.ini
211行 short_open_tag = On 支持php语言的短标记功能
上传discuz包,zip包,要用unzip解压,将upload子目录论坛源文件移动到/var/×××w/html

修改权限
cd /var/×××w/html
chown -R apache *

论坛安装
登录

观察一下数据库
mysql> use ultrax;
mysql> show tables;
mysql> select from pre_common_usergroup ;
mysql> select
from pre_ucenter_members;用户名密码表

下载并运行phpmyadmin
下载,解压,移动,重命名
FTP下载
cd soft
tar zxvf phpMyAdmin-4.0.10.10-all-languages.tar.gz
mv phpMyAdmin-4.0.10.10-all-languages /var/×××w/aa/phpmyadmin
cd /var/×××w/aa/phpmyadmin/

http://×××w.wang.com/phpmyadmin/

输入数据库的用户名和密码
管理数据库(网站连接数据库用户名)

作业:
1、LAMP下建立论坛。