Linux下安装Apache服务

来源:互联网 发布:九章算法 大数据 编辑:程序博客网 时间:2024/05/21 21:42

安装GCC

安装命令: yum -y install gcc

安装Apache前准备:

检查该环境中是否已经存在httpd服务的配置文件,默认存储路径:/etc/httpd/httpd.conf(这是centos预装的Apache的一个ent版本,一般我们安装源代码版的Apache)。如果已经存在/etc/httpd/httpd.conf,请先卸载或者关闭centos系统自带的web服务,执行命令:chkconfig httpd off,再或者把centos自带的httpd服务的80端口改为其他端口,只要不与我们安装的Apache服务的端口冲突就可以啦。

停止并卸载Linux系统自带的httpd服务
  1. service httpd stop
  2. ps -ef | grep httpd
  3. kill -9 pid号(逐个删除)
  4. rpm -qa |grep httpd
  5. rpm -e httpd软件包
[root@localhost bin]# find / -name httpd.conf[root@localhost bin]#

下载安装包

  1. httpd-2.2.23.tar.gz
  2. apr-1.4.5.tar.gz、apr-util-1.3.12.tar.gz
  3. pcre-8.31.tar.gz

httpd-2.2.23版本编译命令

./configure --prefix=/usr/local/apache2 (安装目录参数后面可以不加任何参数,直接安装即可)makemake install    

httpd-2.4.3版本编译命令

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre (除了指定Apache的安装目录外,还要安装apr、apr-util、pcre,并指定参数)makemake install

解决apr not found问题

[root@localhost bin]# tar -zxf apr-1.4.5.tar.gz[root@localhost apr-1.4.5]# ./configure --prefix=/usr/local/apr[root@localhost apr-1.4.5]# make[root@localhost apr-1.4.5]# make install

解决APR-util not found问题

[root@localhost bin]# tar -zxf apr-util-1.3.12.tar.gz[root@localhost apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config[root@localhost apr-util-1.3.12]# make[root@localhost apr-util-1.3.12]# make install

解决pcre-config for libpcre not found问题

[root@localhost ~]# unzip pcre-8.31.zip[root@localhost ~]# cd pcre-8.31[root@localhost pcre-8.31]# ./configure --prefix=/usr/local/pcre[root@localhost pcre-8.31]# make[root@localhost pcre-8.31]# make install

如果已经存在/etc/httpd/httpd.conf,请先卸载或者关闭centos系统自带的web服务,执行命令:chkconfig httpd off,再或者把centos自带的httpd服务的80端口改为其他端口,只要不与我们安装的Apache服务的端口冲突就可以啦。• 启动Apache:/usr/local/apache2/bin/apachectl start• 停止Apache:/usr/local/apache2/bin/apachectl stop• 重启Apache:/usr/local/apache2/bin/apachectl restart

0 0
原创粉丝点击