CentOS6.8 x86_64bit安装apache

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS6.8 x86_64bit安装apache相关的知识,希望对你有一定的参考价值。

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 [email protected]
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 [email protected]
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 [email protected]
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

以上是关于CentOS6.8 x86_64bit安装apache的主要内容,如果未能解决你的问题,请参考以下文章

CentOS6.8 x86_64bit安装apache

CentOS6.8 x86_64bit mysql-5.5.57多实例安装

CentOS6.8 x86_64bit安装PHP-5.3.27

CentOS6.8 x86_64bit MySQL主从复制

CentOS6.8 x86_64bit MySQL简单语句应用

CentOS6.8 x86_64bit shell脚本实现模拟nginx服务启动与关闭