apache-2.2.34安装
1.安装基础依赖包
yum install zlib zlib-devel -y
2.创建安装目录并进入该目录上传已下载好的软件
cd /home/rcih/tools
rz -y ' httpd-2.2.34.tar.gz '
3.解压软件并进入解压好的目录下
tar xf httpd-2.2.34.tar.gz
cd httpd-2.2.34
4.开始编译安装
./configure --prefix=/application/apache2.2.34 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
make&&make install
5.安装完毕后进入到apache的站点目录下创建虚拟主机的目录
cd /application/apache/htdocs/
mkdir bbs www blog
6.修改apache的配置文件,打开包含虚拟主机的配置文件的配置信息注释
cd /application/apache/conf
vim httpd.conf
......
Include conf/extra/httpd-vhosts.conf
......
7.进入apache目录下的配置目录下extra下面修改虚拟主机的配置文件
cd /application/apache/conf/extra
cp httpd-vhosts.conf httpd-vhosts.conf.bak
vim /application/apache/conf/extra/httpd-vhosts.conf
##############################################################
<VirtualHost *:80>
ServerAdmin 123456789@qq.com
DocumentRoot "/application/apache2.2.34/htdocs/www"
ServerName www.rich.com
ServerAlias rich.com
ErrorLog "logs/www-error_log"
CustomLog "logs/www-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin 123456789@qq.com
DocumentRoot "/application/apache2.2.34/htdocs/bbs"
ServerName bbs.rich.com
ServerAlias rich.com
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin 123456789@qq.com
DocumentRoot "/application/apache2.2.34/htdocs/blog"
ServerName blog.rich.com
ServerAlias rich.com
ErrorLog "logs/blog-error_log"
CustomLog "logs/blog-access_log" common
</VirtualHost>
8.修改apache安装目录下的启动配置文件
vim /application/apache/conf/httpd.conf
......
ServerName 127.0.0.1:80
.......
Options -Indexes FollowSymLinks
......
9.修改本地主机的hosts文件,添加IP与主机名的解析,根据自身主机名来修改
vim /etc/hosts
......
172.16.1.248 lamp
......
10.进入到刚创建的apache的站点目录下虚拟主机的目录并创建索引文件
cd /application/apache/htdocs
echo 'apache www' >www/index.html
echo 'apache bbs' >bbs/index.html
echo 'apache blog' >blog/index.html
11.测试语法并启动apache服务
/application/apache/bin/apachectl -t
/application/apache/bin/apachectl start
12.测试服务是否成功启动
netstat -lntup|grep httpd
13.本地主机测试curl www.rich.com
原文链接:/centos/374767.html