Apache源码安装、基于域名虚拟机测试
来源:互联网 发布:万能端口检测工具 编辑:程序博客网 时间:2024/06/14 11:33
1、 安装wget、gcc、lynx(httpd2.4在centos6上安装依赖包)
yum -y install wget gcc gcc-c++ expat expat-devel openssl-devel lynx
2、 安装apr(由于httpd2.4需要apr1.4版本及以上)
wget -c -P /src http://mirror.bit.edu.cn/apache/apr/apr-1.6.2.tar.gz
tar zxvf /src/apr-1.6.2.tar.gz -C /src
cd /src/apr-1.6.2
./configure --prefix=/usr/local/apr
make&&make install
3、 安装apr-util(由于httpd2.4需要apr1.4版本及以上)
wget -c -P /src http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.0.tar.gz
tar zxvf /src/apr-util-1.6.0.tar.gz -C /src
cd /src/apr-util-1.6.0
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr
make&&make install
4、 安装pcre
wget -c -P /src https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz
tar zxvf /src/pcre-8.41.tar.gz -C /src
cd /src/pcre-8.41
./configure --prefix=/usr/local/pcre
make&&make install
5、 安装httpd(源码安装)
wget -c -P /src https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.28.tar.gz
或
wget -c -P /src http://mirrors.sohu.com/apache/httpd-2.4.28.tar.gz
tar zxvf /src/httpd-2.4.28.tar.gz -C /src
cd /src/httpd-2.4.28
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
--enable-so 开启动态库
--enable-rewrite 开启rewrite规则
--enable-ssl 启用https
make
make install
6、 配置apache为系统服务
cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
centos7下需要做以下配置:
编辑vim /etc/init.d/httpd在#!/bin/sh下添加以下配置:
#chkconfig: 234570 70
#description:apache
chkconfig –add httpd
这样就可以使用systemctl start|stop|status httpd.service 命令启动|停止|状态7、 启动apache(需配置httpd.conf中ServerName)
service httpd start
查看端口监听和进程情况
netstat -antp | grep httpd
ps -ef | grep httpd
8、 配置Apache虚拟主机
开启虚拟主机配置,注释掉httpd.conf中Include conf/extra/httpd-vhosts.conf
vim /usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost*:80>
ServerAdmin admin@asiainfo.com
DocumentRoot "/usr/local/apache/htdocs/test1"
ServerName www.test1.com
#ServerAlias www.test.example.com
ErrorLog "logs/test1.error_log"
CustomLog "logs/test1.access_log"common
<Directory"/usr/local/apache/htdocs/test1">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost*:80>
ServerAdmin admin@asiainfo.com
DocumentRoot "/usr/local/apache/htdocs/test2"
ServerName www.test2.com
ErrorLog "logs/test2.error_log"
CustomLog "logs/test2.access_log"common
<Directory"/usr/local/apache/htdocs/test2">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
9、 创建发布目录,写入测试页面
mkdir -p /usr/local/apache/htdocs/{test1,test2}
echo "This is test1 page" >/usr/local/apache/htdocs/test1/index.html
echo "This is test2 page" >/usr/local/apache/htdocs/test2/index.html
10、重启apache、关闭selinux、iptables
service httpd restart
service iptables stop
setenforce 0
11、测试机上添加hosts
vi /etc/hosts
192.168.241.133 www.test1.com
192.168.241.133 www.test2.com
测试:
curl www.test1.com
curl www.test2.com
12、虚拟主机配置文件详细参数
<VirtualHost *:80>
ServerAdmin admin@asiainfo.com 管理员邮箱地址
DocumentRoot "/usr/local/apache/htdocs/test1" 发布目录
ServerName www.test1.com 域名
ErrorLog "logs/test1.error_log" 错误日志
CustomLog "logs/test1.access_log" common 正常日志
<Directory "/usr/local/apache/htdocs/test2">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Order allow,deny 默认禁止所有客户端访问
Order deny,allow 默认允许所有客户端访问
Allow from all 允许所有客户端访问
- Apache源码安装、基于域名虚拟机测试
- windows xp 下Ubuntu虚拟机安装及Apache安装测试
- 自己测试apache绑定域名
- apache服务器安装虚拟机
- Apache基于域名的虚拟主机(Windows)
- apache基于域名和端口的虚拟主机
- Apache基于域名的虚拟主机 别名
- apache基于主机的域名指向
- centos apache 基于域名的虚拟主机
- Apache配置基于域名的虚拟主机
- apache基于域名的虚拟主机配置
- Apache虚拟主机(基于IP、基于端口、基于域名)
- 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机
- 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机
- 源码安装xen虚拟机
- 测试环境-虚拟机安装
- 配置apache虚拟机(ip访问和域名访问)
- apache 的安装与增加域名
- 1016作业
- U-BOOT-2016.07移植 (第二篇) 添加单板
- iOS 修改UIPageControl样式
- mouseout 和 mouseleave 之间的一些不同
- 缓冲运动(变速)
- Apache源码安装、基于域名虚拟机测试
- Android设计模式之单例模式
- Question about the study of Qt
- 使用Kotlin开发Android项目-Kibo(一)
- 获取网络的工具类
- Duplicate entry '0' for key 'PRIMARY'
- Android必学之数据适配器BaseAdapter
- 机器学习基石-01-the learning problem
- RadioGroup点击RadioButtion切换Fragment