在centos6.5mini系统上编译安装Apache

若是是VMware虚拟机,网卡要求“桥接html

一、编译安装前首先yum 安装“开发环境”“兼容库”“中文支持”即执行以下命令linux

#yum groupinstall "Development tools" "Compatibility libraries" "Chinese Support [zh]" -yapache

安装man, vim, wget 工具vim

#yum install man vim wget -y浏览器


二、由于此次要编译安装httpd2.4.25,此版本须要更高版本的apr和apr-util。ide

所以要首先编译安装apr和apr-util。工具

wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.bz2spa

wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.bz2orm


2.1编译安装aprserver

tar xf apr-1.5.2.tar.bz2

cd apr-1.5.2

./configure --prefix=/usr/local/apr

echo $?  ###若是执行结果是0,则继续执行make && make install


2.2编译安装apr-util

tar xf apr-util-1.5.4.tar.bz2

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

echo $?  ###若是执行结果是0,则继续执行make && make install


三、重量级选手出厂了,正式开始编译httpd-2.4.25

wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.25.tar.bz2

屡次编译经验得知,缺乏pcre相关文件,openssl is too old

执行以下命令:

yum install pcre-devel openssl openssl-devel -y


tar xf httpd-2.4.25

cd httpd-2.4.25

./configure  --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/

wKiom1kBvmmQbf0fAAAvUqVS7T4228.png-wh_50

有如上提示则继续执行:make && make install

再执行echo$?若是结果是0,则说明httpd2.4.25到此编译成功,而后进行简单的配置,就能够使用了


四、配置httpd

关闭linux防火墙

service httpd stop

关闭SELinux

setenforce 0


复制启动文件

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd


把httpd的环境变量添加到“环境变量”

echo 'export PATH=$PATH:/usr/local/apache/bin' > /etc/profile.d/httpd.sh

chmod +x /etc/profile.d/httpd.sh

source /etc/profile.d/httpd.sh


编辑httpd的配置文件:

vim /etc/httpd/httpd.conf

在ServerRoot下一行,添加 ServerName localhost


若是想把Apache服务加入到开机启动,能够修改服务启动脚本:

vim /etc/init.d/httpd

在第二行下添加:# chkconfig:235 85 15

                # description: This is apache server

保存退出

执行命令service httpd start #提示lynx找不到???那就yum install lynx -y


执行命令netstat -ntlp #查看httpd是否启动,是否有80端口

最后在你的浏览器输入虚拟机IP地址

It works!

则Apache,安装成功


一、编译安装--默认的index.html首页在/usr/local/apache/htdocs

二、配置文件:/etc/httpd/httpd.conf

三、启动脚本:/etc/init.d/httpd

四、cgi-bin文件目录:/etc/local/apache/cgi-bin

相关文章
相关标签/搜索