首页 » Apache » 正文

linux下安装apache

1.将文件上传到目录/usr1 下

blob.png

2.cd /usr1

3.tar jxvf httpd-2.4.1.tar.bz2

4.cd httpd-2.4.1

5../configure –help | more

6../configure –prefix=/usr1/apache –enable-so

blob.png

遇到问题了,我们先安装apr

下载地址:http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
将下载的文件上传到目录/usr/local/目录下

blob.png

cd /usr/local

tar -zxf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure –prefix=/usr/local/apr

make && make install

 

 

7.再次执行

cd /usr1/httpd-2.4.1
./configure –prefix=/usr1/apache –enable-so

blob.png

报错apr-util不存在

继续安装apr-util

下载:http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz

cd /usr/local/

tar -zxf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure –prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config

make && make install

 

8.再次执行

cd /usr1/httpd-2.4.1
./configure –prefix=/usr1/apache –enable-so –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/

make

make install

cd /usr1/apache
cd conf/

cp -a httpd.conf httpd.conf-

chkconfig –list httpd //查看httpd服务是否已存在

chkconfig httpd off

service httpd status

/usr1/apache/bin/apachectl -k start

netstat -an | grep :80

ps -aux | grep httpd

cd ../..
cp /usr1/apache/bin/apachectl /etc/rc.d/init.d/apache

[root@localhost local]#vi /etc/rc.d/init.d/apache // 这里是编辑apache启动脚本
在开头的#!/bin/sh 下面加上
#chkconfig: 2345 85 15

——————————————————————–

root@localhost local]#chkconfig –add apache //添加apache服务
[root@localhost local]#chkconfig –list apache //列出apache服务
[root@localhost local]#service apache stop //停止apache服务
[root@localhost local]#netstat -an | grep :80 //查看linux的80端口是否关闭
[root@localhost local]#ps -aux | grep httpd //查看是否存在httpd服务,若果之前自带httpd服务启动的话会导致新添加的apache服务启动失败
[root@localhost local]#service apache start //启动apache服务
打开你的服务器ip地址,看看是否出现了tomcat的默认首页,如果出现的话,那么恭喜你
linux下安装apache已经成功了

 

根据需求编辑相关配置文件

vi  /usr1/apache/httpd.conf

apache项目上传目录为:/usr1/apache/htdocs

页面请求地址为:http://192.168.2.112/index.html

 

代下载网站转载,原文链接:

http://www.noaccount.cn/article/30091245.html