(10)Linux_服务篇_Apache
Apache服务器
1. 下载地址:wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.2.32.tar.bz2
解压源码包:tar -jxvf httpd-2.2.32.tar.bz2
源码安装步骤:(1) cd httpd-2.2.32 : ./configure --prefix=/usr/local/apache2/ ------- 预编译 配置检测,并指定要安装的路径
(2) cd httpd-2.2.32 : make -------- 编译
(3) cd httpd-2.2.32 : make install ------- 安装
(4) 启动安装文件:/usr/local/apache2/bin/httpd -k start
(5) 修改配置文件:vim /usr/local/xxxx/conf/xxxd.conf
(1) 去除#跟空行:grep -v "#" httpd.conf|grep -v "^$"
(6) 启动服务:/usr/local/xxxx/bin/xxxxd start
(7) 访问服务应用:
(8) 服务的优化:
2. Apache源码编译的发布目录:/usr/local/apache2/htdocs
3. Apache虚拟主机配置 --- 发布多个网站:vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80 ---- 定义的虚拟主机监听的端口 ;* ---- 监听的任意IP
####发布某个网站
<VirtualHost *:80>
ServerAdmin test.net
DocumentRoot "/usr/local/apache2/htdocs/" ----- 发布目录
ServerName www.test.com ---- 域名
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>
4. /var/www/html/:网站根目录;该目录是apache默认存放首页的目录
5./var/www/error/:存放服务器设置错误,浏览器请求数据的错误
7. /var/www/icons/:存放小图标
8. /var/log/httpd/:默认apache日志文件都放在这里
9. /usr/bin/htpasswd:直接访问某个页面路径时,设置apache密码保护; 对某个目录限制访问