linux 安装 apache

安装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软件包

[[email protected] bin]# find / -name httpd.conf
[[email protected] bin]#

二, 下载Apache安装包 httpd-2.4.10.tar.gz ,下载地址:http://httpd.apache.org/
在安装Apache时,我分别针对不同版本进行了安装,在编译时是不同的,configure后跟的参数不同。

./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,并指定参数)
make
make install

在编译Apache(在安装httpd-2.4.10时遇到的问题)时分别出现了apr not found、APR-util not found、pcre-config for libpcre not found的问题,下面就httpd-2.4.10的这些问题解决来实际操作一把。

1, 解决apr not found问题

[[email protected] bin]# tar -zxf apr-1.4.5.tar.gz
[[email protected] apr-1.4.5]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.4.5]# make
[[email protected] apr-1.4.5]# make install

2.解决APR-util not found问题

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

3、解决pcre-config for libpcre not found问题

[[email protected] ~]# unzip pcre-8.31.zip

[[email protected] ~]# cd pcre-8.31

[[email protected] pcre-8.31]# ./configure --prefix=/usr/local/pcre

[[email protected] pcre-8.31]#

make[[email protected] pcre-8.31]# make install

apache服务自启动设置

[email protected]#cp /usr/local/apahe/bin/apachectl /etc/rc.d/init.d/httpd
[email protected]#vim /etc/rc.d/init.d/httpd

在httpd中加入
#chkconfig: 35 85 15
#description: apache
保存退出。

[email protected]# chkconfig --add httpd
[email protected]# chkconfig httpd on

查看一下是否添加成功:

chkconfig --list httpd

测试:
[email protected]# service httpd start

如报 AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using localhost.localdomain. Set the ‘ServerName‘ directive globally to suppress this message

Apache的配置文件则是conf目录下的httpd.conf文件,将其打开:

找到ServerName(约213行),将其设置为localhost:80,并将前面的井号删除

测试:

[[email protected] ~]# curl http://localhost

<html><body><h1>It works!</h1></body></html>

时间: 2024-08-24 02:22:51

linux 安装 apache的相关文章

manjaro linux 安装 Apache,MariaDB,PHP(LAMP)

manjaro linux 安装 Apache,MariaDB,PHP(LAMP) root 身份执行下面的命令 1. 升级系统 pacman -Syu 2. 安装 Apache 升级完后,安装Apache pacman -S apache 编辑 /etc/httpd/conf/httpd.conf file nano /etc/httpd/conf/httpd.conf # 我这里用的nano,你可用其它的编辑器只要能编辑文本就行 找到LoadModule unique_id_module m

【问题记录】 Linux 安装 apache 遇到的一些问题

以下为linux上安装apache时自己遇到的一些问题,记录在这,以后遇到时也会不定时更新... 一.安装Apache提示APR not found的解决办法 解决方法: 1. 网站 http://apr.apache.org/download.cgi 下载 apr-1.5.1.tar.gz .apr-util-1.5.4.tar.gz 2. 网站 http://www.pcre.org/ 下载 pcre-8.36.tar.gz 3.依次解压.安装 附相关命令: 1 [[email protec

LInux——安装Apache

在安装Apache的httpd的时候经常会遇到: configure: error: APR not found .  Please read the documentation. configure: error: APR-util not found .  Please read the documentation. configure: error: pcre-config for libpcre not found. PCRE is required and available 网上也有

linux 安装apache 2.4.9+php 7.0.28

安装准备工作yum install -y apr- gcc- libpcre- pcre- openssl-*由于系统包中的curl版本低不支持,所以需要手动下载安装wget https://curl.haxx.se/download/curl-7.59.0.tar.gztar -xf curl-7.59.0.tar.gzcd curl-7.59.0./configure make && make installwget ftp://mcrypt.hellug.gr/pub/crypto/

Linux安装Apache报错:Cannot find a valid baseurl for repo: base/7/x86_64解决方案

最近使用CentOS7学习,安装安装Apache时候,使用yum安装Apache报错:本文适合CentOS7和RHEL7 # yum install httpd 出现:cannot find a valid baseurl for repo:base/7/x86_64. 针对这个问题,网上有大量的解决方案,说是网络不通的,比如: 修改: vi /etc/sysconfig/network-scripts/ifcfg-eth0(每个机子都可能不一样,但格式会是"ifcfg-eth数字")

Linux安装Apache

一.查看版本 httpd -d 二.安装过程 1.参考过程 http://weizhilizhiwei.iteye.com/blog/2041961 设置目录命令 ./configure --prefix=/usr/local/web/apache 2.如果需要安装arp.arp-util可参考 http://davis.zhang2004.blog.163.com/blog/static/2276015220128131455729/ 不用安装pcre 3.启动httpd service ht

linux 安装apache、tomcat问题汇总

1.linux下安装安装pcre-8.32 ./configure --prefix=/usr/local/pcre 出现以下错误 configure: error: You need a C++ compiler for C++ support 解决方法: yum install -y gcc gcc-c++ 2.apache 装完后再浏览器输入localhost地址,报httpd: Could not reliably determine the se...错 解决方法:报此错的原因是apa

Linux安装apache/php/mysql

Linux下的mysql apache php rpm安装方法步骤 1.安装光盘上自带的httpd-2.2.3-5.i386.rpm这个包,是apache,如果安装过程中提示需要什么其他的包,看提示装上. 2.接着安装光盘自带的php-5.1.6-3.i386.rpm这个包,会提示需要其他的包,装. 3.用vi编辑/etc/httpd/conf/httpd.conf这个文件,在其中添加 LoadModule php5_module /usr/lib/httpd/modules/libphp5.s

linux 安装apache源码

环境介绍: 系统环境:CentOS6.4 所需软件包:apr-1.4.2.tar.gz.apr-util-1.4.2.tar.gz.httpd-2.2.32.tar.gz 注意:官方网站提示apr/arp-util版本要1.4(含)版本以上. 依赖包:zlib-devel # yum install zlib-devel 开发环境包组:Development Tools, Server Platform Development # yum groupinstall "Development To