`

Linux64下安装配置Apache

阅读更多

 

下载:wget http://apache.dataguru.cn//httpd/httpd-2.2.3.tar.gz

 

# tar -zxvf httpd-2.2.3.tar.gz
# cd httpd-2.2.3
# ./configure LDFLAGS="-L/usr/lib64 -L/lib64" --prefix=/usr/local/apache

 

# vi ./srclib/apr-util/Makefile
修改,将
 

APRUTIL_LIBS = -lsqlite3 /usr/lib/libexpat.la /root/tar/httpd-2.2.3/srclib/apr/libapr-1.la -luuid -lrt -lcrypt -lpthread -ldl

改为:
 

APRUTIL_LIBS = -lsqlite3 /usr/lib64/libexpat.la /root/tar/httpd-2.2.3/srclib/apr/libapr-1.la -luuid -lrt -lcrypt -lpthread -ldl
# make
# make install

一直命令行闪动,一会就可以安装好了。

 

参考另外:

http://www.server110.com/apache/201308/87.html

 

安装前准备:下载httpd-2.4.10.tar.gz 、apr-1.4.6.tar.gz 、apr-util-1.4.1.tar.gz、pcre-8.20.tar.bz2
Apache下载路径:http://httpd.apache.org/
Apr 下载路径:http://apr.apache.org/

将文件上传至Linux /home/ 目录下(可使用软件F-SecureSSHClient-v5.4.56)

 

安装Apache:

wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.10.tar.gz


1. 解压httpd-2.4.10.tar.gz 使用命令tar –zvxf httpd-2.4.10.tar.gz ,解压完后会生成一个httpd-2.4.10的目录
# tar –zvxf httpd-2.4.10.tar.gz
# cd httpd-2.4.10

# ./configure
这里提示一个错误configure: error: APR not found. Please read the documentation.

 

2. 经网上查阅资料才知道这是Apache的关联软件,需要安装APR软件。
这里下载apr-1.4.6.tar.gz 解压安装。
# tar –zvxf apr-1.4.6.tar.gz
# cd apr-1.4.6
# ./configure --prefix=/usr/local/apr
这里说明一下,--prefix表示要将apr安装到哪个目录;如果目录不存在,程序为什么创建;最好加上此参数;我第一次没有加,安装完成后找不到文件了;因为我们在后面的安装中非常需要这个目录;--prefix=绝对路径名
执行完毕后;执行
# make
如果make执行过程中没有 error错误;执行
# make install
如果make install命令执行过程中没有出现任何Error;并且创建了相关的目录;我这里是/usr/local/apr目录。那么恭喜你,你的APR安装完成了;
这里如果执行安装httpd服务的话;就不再会报checking for APR... No configure: error: APR could not be located这个错误了;

 

3. 这里再返回到httpd-2.4.10 目录执行命令:
/configure --prefix=/usr/local/apache --with-apr=/usr/local/apr
这时就会报
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation
这就需要下载相关的APR-UTIL的包。
这里下载的是apr-util-1.4.1.tar.gz 解压安装
# tar –zvxf apr-util-1.4.1.tar.gz
# cd apr-util-1.4.1
# ./configure --prefix=/use/local/apr-util --with-apr=/use/local/ apr/bin/apr-1-config
执行./configure 执行这个文件时需要加上刚才安装完成的apr配置文件; 如果不加此配置文件会报找不到apr异常。
# make
# make install
如果make install能正常执行成功,则会在prefix设置的目录下面有生成相关的配置文件;这时就表示你的apr-util安装成功了


4.再次返回到httpd-2.4.10 目录进行安装,执行命令
# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config
执行过程中没有报错;继续执行make命令
# make
Make执行完成后执行make install
# make install
httpd服务安装完成

 

补充说明:
有些人在安装Apache 第4步的时候执行
# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util/bin/apu-1-config
会出现错误提示:
configure: error: pcre-config for libpcre not found. PCRE is required and available
这里需要下载pcre相关软件上,这里下的pcre版本是pcre-8.35.tar.bz2
下面开始安装pcre
# bzip -d pcre-8.35.tar.bz2
#tar -xvf -d pcre-8.35.tar
#./configure --prefix=/use/local/pcre --with-apr=/usr/local/apr/bin/apr-1-config
进行pcre-8.35目录进行pcre的安装; pcre的安装要需要指定apr如果不指定apr会报找不到apr异常
# make
# make install


安装httpd服务
安装httpd服务需要指定apr apr-util pcre这三个目录才能正常安装;因此他的安装命令是
./configure --prefix=/usr/local/httpd
--with-apr=/usr/local/apr/bin/apr-1-config
--with-apr-util=/usr/local/apr-util/bin/apu-1-config
--with-pcre=/usr/local/pcre/bin/pcre-config

 

修改Apache 配置文件:
1.默认的web根目录为:htddocs。默认端口为80必须修改否则跟系统冲突,端口号改为8088 也可以自己设定一下,根据实际情况进行修改该。
# vi /usr/local/apache/conf/httpd.conf
左右方向键找到 listen 80
输入 i 修改 80 为8088
按 esc 然后shift+: 输入wq 保存退出就好了


2.测试apache服务器
使用此命令是开始了本机的默认的服务
# /usr/local/apache/bin/apachectl -k start
进入安装目录
# cd /usr/local/apache/bin/
# ./apachectl –k start|stop|restart 分别为启动停止 重启
netstat -ltnp 检查网络端口 验证刚才我们的端口号是否打开了
# netstat –ltnp
这时查看我们的端口号是否打开了 结果:8088打开了
打开浏览器 输入 http://IP地址:8088
出现 it works 表示连接已经正常
到此安装完毕


3.配置rc.local文件将Apache的服务加入到开机自动启动
# echo '/usr/local/apache2/bin/apachectl -k start' >> /etc/rc.d/rc.local

如果安装完成之后,发现还报错,可以将apr,apr-util的解压包拷贝至http解压包的srclib/目录下,然后重新安装,这个问题弄了我很长时间,现在写出来,希望对大家有所帮助。
完毕!!!

 

 

yum 安装方式:参考:http://www.paipat.com/?post=24

 之前讲过《linux centos 如何快速部署web服务器-Apache篇》现在就讲讲centos 如何部署Apache,让简单的网站运行。本节比较简单,在非编译下安装,可以满足新手用户的需求。

演示环境:
Linux CentOS 6.3 X64 Apache

一、安装apache及相关组件

1、用ROOT账户进入系统后,开始安装。
#yum install httpd     /安装apache
二、测试apache运行

1、启动apache
#/etc/init.d/httpd start    /启动apache
2、需要时可以查看apache运行状态
#/etc/init.d/httpd status
3、现在可以在浏览器中打开 http://localhost 或 http://127.0.0.1 ,看到 Apache 2 Test Page 页面

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics