Linux安装配置apache

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

1.获取软件: http://httpd.apache.org/  httpd-2.2.21.tar.gz

2.安装步骤:

解压源文件:

 tar zvxf httpd-2.2..tar.gz 
cd httpd-2.2.
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
make
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

Apache遇到的问题:APR not found

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 )
下载:http://apr.apache.org/download.cgi

#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 http://pcre.org/

#./configure –help | grep pcre
--with-pcre=PATH        Use external PCRE library

下载:http://sourceforge.net/projects/pcre
#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 //重启防火墙

linux下apache的使用的更多相关文章

  1. linux 下 apache相关;启动、停止、重启命令;配置文件位置等等

    linux 下 apache启动.停止.重启命 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/usr/l ...

  2. Linux下apache+phppgadmin+postgresql安装配置

    Linux下apache+phppgadmin+postgresql安装配置 操作系统:CentOS 安装包:httpd(首选yum), php(包括php以及php-pgsql,php-mbstri ...

  3. 分享:linux下apache服务器的配置和管理

    linux下apache服务器的配置和管理. 一.两个重要目录: Apache有两个重要的目录:1.配置目录/etc/httpd/conf:2.文档目录/var/www: 二.两种配置模式: Apac ...

  4. linux 下apache安装、启动和配置

    linux 下 apache安装 1:系统安装,这里就不说了,网上有很多,也很简单.顺便说下,我用的是redhat 9: 2:在图形界面下下载apache 安装包,我下的是 httpd-2.2.9.t ...

  5. linux 下 apache启动、停止、重启命令

    原文:linux 下 apache启动.停止.重启命令 基本的操作方法: 本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令: 推荐/u ...

  6. [Linux]Linux下Apache服务器配置

    Linux下Apache服务器配置 相关包: httpd-2.2.3-29.e15.i386.rpm                 //主程序包 httpd-devel-2.2.3-29.e15.i ...

  7. Linux下Apache服务器配置

    Linux下Apache服务器配置 相关包: httpd-2.2.3-29.e15.i386.rpm                 //主程序包 httpd-devel-2.2.3-29.e15.i ...

  8. Linux下Apache服务部署静态网站------网站服务程序

    文章链接(我的CSDN博客): Linux下Apache服务部署静态网站------网站服务程序

  9. linux下apache和tomcat整合

    一 Apache与Tomcat比较联系 apache支持静态页,tomcat支持动态的,比如servlet等. 一般使用apache+tomcat的话,apache只是作为一个转发,对jsp的处理是由 ...

  10. Linux下Apache虚拟主机配置

    Linux下Apache虚拟主机的三种配置.这样可以实现一台主机架构多个独立域名网站.其中基于域名的最为常见.性价比也最高.下面PHP程序员雷雪松详细的讲解下Linux下Apache虚拟主机配置的具体 ...

随机推荐

  1. 【BZOJ-1396&2865】识别子串&字符串识别 后缀自动机/后缀树组 + 线段树

    1396: 识别子串 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 312  Solved: 193[Submit][Status][Discuss] ...

  2. 丢失或损坏NDF文件如何附加数据库

    在论坛看到有人遇到 NDF文件丢失并且没有备份,所以无法成功附加数据库.在网上也看到过很多回答是如果没有NDF就无法附加成功. 其实我自己测试下来即使没有NDF也是可以成功附加的.但是有条件,丢失的N ...

  3. 虚拟信用卡 全球付, 工商银行国际E卡, Bancore, Entropay, Payoneer

    虚拟信用卡 海外网购.购买国外域名空间.ebay等一些国外网站账号的激活这些情况都需要用到国际信用卡, 如果没有信用卡或者有信用卡但是对于安全性有所顾虑怎么办? 其实有一种东西叫做虚拟信用卡,正规银行 ...

  4. sql 递归查询所有的下级

    --> 生成测试数据表: [tb] IF OBJECT_ID('[Users]') IS NOT NULL     DROP TABLE [Users] GO CREATE TABLE [Use ...

  5. Access-Control-Allow-Origin,跨域

    1.浏览器的同源安全策略 浏览器只允许请求当前域的资源,而对其他域的资源表示不信任.那怎么才算跨域呢? 请求协议http,https的不同 域domain的不同 端口port的不同 好好好,大概就是这 ...

  6. JavaScript 新手的踩坑日记

    引语 在1995年5月,Eich 大神在10天内就写出了第一个脚本语言的版本,JavaScript 的第一个代号是 Mocha,Marc Andreesen 起的这个名字.由于商标问题以及很多产品已经 ...

  7. 用最简单的例子理解策略模式(Strategy Pattern)

    当一个动作有多种实现方法,在实际使用时,需要根据不同情况选择某个方法执行动作,就可以考虑使用策略模式. 把动作抽象成接口,比如把玩球抽象成接口. public interface IBall { vo ...

  8. wireshark提取gzip格式的html

    原文地址:http://blog.csdn.net/vah101/article/details/44102501 首先使用wireshark启动抓包,然后以百度为例,访问百度的首页,之后停止抓包,w ...

  9. 【docker-compose】使用docker-compose启动spring-boot+mysql,服务内连数据库报错:create connection SQLException, url: jdbc:mysql://mysql:33061/swapping?useSSL=false&useUnicode=true&characterEncoding=UTF-8, errorCode 0,

    完整配置在这里, https://www.cnblogs.com/sxdcgaq8080/p/10070948.html 启动报错如下: 2018-12-05 01:04:05.569 ERROR 1 ...

  10. 在oracle中查询已知表名的表中所有字段名,每个字段是否是主键,是否是外键,是否为空的sql语句

    查询表的所有列及其属性:select t.*,c.COMMENTS from user_tab_columns t,user_col_comments c where t.table_name = c ...