博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下apache的使用
阅读量:7116 次
发布时间:2019-06-28

本文共 3903 字,大约阅读时间需要 13 分钟。

http://www.cnblogs.com/fly1988happy/archive/2011/12/14/2288064.html

1.获取软件:   httpd-2.2.21.tar.gz

2.安装步骤:

解压源文件:

1 tar zvxf httpd-2.2.21.tar.gz 2 cd httpd-2.2.21 3 ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite 4 make 5 make install

运行./configure 命令进行编译源代码,

--prefix=/usr/local/apach2 是设置编译安装到的系统目录,

 --enable-s  参数是使httpd服务能够动态加载模块功能,

--enable-rewrite  是使httpd服务具有网页地址重写功能。

3.启动apache:

/usr/local/apache2/bin/apachectl start

4.将apache加入到系统服务,用service命令来控制apache的启动和停止

  •  首先以apachectl脚本为模板生成Apache服务控制脚本:

  grep -v "#" /usr/local/apache2/bin/apachectl  > /etc/init.d/apache

  • 用vi编辑Apache服务控制脚本/etc/init.d/apache:

  vi /etc/init.d/apache

  • 在文件最前面插入下面的行,使其支持chkconfig命令:

  #!/bin/sh              

  # chkconfig: 2345 85 15              

  # description: Apache is a World Wide Web server.

  • 保存后退出vi编辑器,执行下面的命令增加Apache服务控制脚本执行权限:    

  chmod  +x  /etc/init.d/apache

  • 执行下面的命令将Apache服务加入到系统服务:    

  chkconfig --add apache

  • 执行下面的命令检查Apache服务是否已经生效:    

  chkconfig --list apache              

  • 命令输出类似下面的结果:              

  apache          0:off 1:off 2:on 3:on 4:on 5:on 6:off       

  表明apache服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制Apache的启动和停止。  

  • 启动Apache服务:   service apache start   
  • 停止Apache服务:        service apache stop   
  • 执行下面的命令关闭开机自启动:      chkconfig apache off

 

http://www.cnblogs.com/JemBai/archive/2012/11/07/2759139.html

#./configure --prefix……检查编辑环境时出现:

checking for APR... no

configure: error: APR not found .  Please read the documentation.

可以用./configure –help | grep apr 查看帮助。

--with-included-apr     Use bundled copies of APR/APR-Util
--with-apr=PATH         prefix for installed APR or the full path to apr-config
--with-apr-util=PATH    prefix for installed APU or the full path to
安装APR(Apache Portable Runtime )
下载:

#cd /tmp/52lamp/ //源码存放位置

#tar -zxvf apr-1.4.2.tar.gz //unzip -o apr-1.4.2.zip
#cd apr-1.4.2
#./configure
#make
#make install

再次检查编译环境出现

checking for APR-util... no

configure: error: APR-util not found .  Please read the documentation.

#./configure –help | grep apr-util

--with-apr-util=PATH    prefix for installed APU or the full path to

下载:http://download.chinaunix.net/download/0001000/472.shtml

#tar -zxvf apr-util-1.3.9.tar.gz
#cd apr-util-1.3.9
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#make
#make install

./configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现

configure: error: pcre-config for libpcre not found. PCRE is required and available from 

#./configure –help | grep pcre

--with-pcre=PATH        Use external PCRE library

下载:

#unzip -o pcre-8.10.zip
#cd pcre-8.10
#./configure --prefix=/usr/local/pcre
#make
#make install

继 续安装Apache/httpd,./configure 时加上参数 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre,这个问题就解决了

注意:Apache在安装时不会检查参数是否正确,错误的参数会直接被丢弃,不会报告给用户。但可以使用echo $?命令检查是否有错误,当输出结果为0时表示没有错误。

#echo $?

0

#make

#make install

复制Apache启动文件

#cp /usr/local/httpd/bin/apachectl /sbin/

启动Apache

#apachectl start

设置Apache开机自启动

#vi /etc/rc.d/rc.local
增加一行 /sbin/apachectl start

或者将httpd服务添加到ntsysv服务管理工具

#apachectl stop //关闭Apache以免不必要的麻烦
#cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
#vi /etc/rc.d/init.d/httpd
修改为
#!/bin/sh
#
#chkconfig: 345 85 15 //#不能省略,注意空格
#description: httpd for 52lamp 20101016 21:54 //任意字符串
#
......

第二行中345的含义:

#       0 - operation completed successfully
#       1 -
#       2 - usage error
#       3 - httpd could not be started
#       4 - httpd could not be stopped
#       5 - httpd could not be started during a restart

修改有关权限

#cd /etc/rc.d/init.d/
#chmod a+x httpd
#chkconfig --add httpd

#ntsysv

httpd已经在列表中,按F1可以看到刚才编写的服务描述httpd for 52lamp 20101016 21:54。

#apachectl start

#ps -e |grep httpd
23247 ?        00:00:00 httpd
23248 ?        00:00:00 httpd
23249 ?        00:00:00 httpd
23251 ?        00:00:00 httpd
23252 ?        00:00:00 httpd

在浏览器中输入127.0.0.1,看起来一切正常;但是局域网内其他电脑不能访问!

#service iptables stop

如果不想关闭防火墙,放开80端口即可。

#vi /etc/sysconfig/iptables

增加一行-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
#service iptables restart //重启防火墙

 

你可能感兴趣的文章
mac下设置eclipse自动提示
查看>>
IntelliJ IDEA中日志分类显示设置
查看>>
数据结构思维 第十六章 布尔搜索
查看>>
独家|从满天飞舞到逐步落地,自动驾驶好消息只会越来越多
查看>>
如何找到后台运行的隐藏程序
查看>>
多维防护:虚拟化安全挑战的破解之道
查看>>
从羽泉到智能硬件,离婚后的胡海泉走过了一条什么样的道路?
查看>>
VR训练营第一期:聊聊全景拍摄和直播那点事
查看>>
Ubuntu 16.04下ssh启用root登录
查看>>
2016中国大数据大会暨大数据年度盛典将于12月20日在京举办
查看>>
双11大幕拉开,菜鸟智能机器人也将测试运行
查看>>
Mac OS 10.12使用SecureCRT 8.1.4无法保存密码的问题解决
查看>>
windbg调试实例(4)--句柄泄露
查看>>
关于directX最近的学习方案
查看>>
Maven在Eclipse中的实用小技巧
查看>>
红黑树
查看>>
常见自动化测试工具,你用过哪些?
查看>>
JdbcTemplate使用小结
查看>>
2014 网选 5011 Game(Nim游戏,数学题)
查看>>
微软官方windows phone开发视频教程第一天视频(附下载地址)
查看>>