CentOS-7下安装apache

1、 安装包准备

1、 apr-1.5.2.tar.gz

2、 apr-util-1.5.4.tar.gz

3、 pcre-8.37.tar.gz

4、 httpd-2.4.3.tar.gz

5、 php-5.6.15.tar.gz

2安装httpd-2.4.3.tar.gz

1、[root@ipc1 httpd-2.4.3]# tar -zxvf httpd-2.4.3.tar.gz

2、[root@ipc1 httpd-2.4.3]# cd httpd-2.4.3/

3、[root@ipc1 httpd-2.4.3]# ./configure

提示信息如下:

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for APR... no

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

没有安装 apr-1.5.2.tar.gz 接下来安装 apr-1.5.2.tar.gz

3安装apr-1.5.2.tar.gz

1、 解压缩apr-1.5.2.tar.gz

[root@ipc1 php]# tar -zxvf apr-1.5.2.tar.gz

[root@ipc1 php]# cd apr-1.5.2/

2、 编译apr-1.5.2.tar.gz

[root@ipc1 apr-1.5.2]# ./configure

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

Configuring APR library

Platform: x86_64-unknown-linux-gnu

checking for working mkdir -p... yes

APR Version: 1.5.2

checking for chosen layout... apr

checking for gcc... no

checking for cc... no

checking for cl.exe... no

configure: error: in `/usr/local/soft/php/apr-1.5.2':

configure: error: no acceptable C compiler found in $PATH

See `config.log' for more details

3、出现此错误是因为没有安装gcc编译器

[root@ipc1 apr-1.5.2]# yum -y install gcc

4、安装gcc编译器,编译完毕后继续执行以下操作

[root@ipc1 apr-1.5.2]# ./configure

[root@ipc1 apr-1.5.2]# make

[root@ipc1 apr-1.5.2]# make install

5、执行完毕后,继续安装httpd-2.4.3

[root@ipc1 httpd-2.4.3]# ./configure

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for APR... yes

  setting CC to "gcc"

  setting CPP to "gcc -E"

  setting CFLAGS to " -g -O2 -pthread"

  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"

  setting LDFLAGS to " "

configure:

configure: Configuring Apache Portable Runtime Utility library...

configure:

checking for APR-util... no

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

没有安装apr-util-1.5.4.tar.gz接下来安装 apr-util-1.5.4.tar.gz

4安装apr-util-1.5.4.tar.gz

1、[root@ipc1 php]# tar -zxvf apr-util-1.5.4.tar.gz

2、[root@ipc1 php]# cd apr-util-1.5.4/

3、[root@ipc1 apr-util-1.5.4]# ./configure

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking for working mkdir -p... yes

APR-util Version: 1.5.4

checking for chosen layout... apr-util

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

Applying apr-util hints file rules for x86_64-unknown-linux-gnu

checking for APR... no

configure: error: APR could not be located. Please use the --with-apr option.

4、指定编译参数

[root@ipc1 apr-util-1.5.4]# ./configure --with-apr=/usr/local/apr

[root@ipc1 apr-util-1.5.4]# make

[root@ipc1 apr-util-1.5.4]# make install

5、执行完毕后,继续安装httpd-2.4.3

[root@ipc1 httpd-2.4.3]# ./configure

[root@ipc1 httpd-2.4.3]# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for APR... yes

  setting CC to "gcc"

  setting CPP to "gcc -E"

  setting CFLAGS to " -g -O2 -pthread"

  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"

  setting LDFLAGS to " "

configure:

configure: Configuring Apache Portable Runtime Utility library...

configure:

checking for APR-util... yes

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking how to run the C preprocessor... gcc -E

checking for gcc option to accept ISO C99... -std=gnu99

checking for pcre-config... false

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

6、 没有安装pcre-8.37.tar.gz接下来安装 pcre-8.37.tar.gz

5安装pcre-8.37.tar.gz

1、[root@ipc1 php]# tar -zxvf pcre-8.37.tar.gz

2、[root@ipc1 php]# cd pcre-8.37/

3、[root@ipc1 apr-util-1.5.4]# ./configure

4、[root@ipc1 pcre-8.37]# ./configure

报错:configure: error: You need a C++ compiler for C++ support.

[root@ipc1 pcre-8.37]# yum install -y gcc gcc-c++ 即可

5、[root@ipc1 pcre-8.37]# make

6、[root@ipc1 pcre-8.37]# make install

6、 安装httpd-2.4.3.tar.gz

1、[root@ipc1 php]# cd httpd-2.4.3/

2、[root@ipc1 httpd-2.4.3]# make

3、[root@ipc1 httpd-2.4.3]# make install

Apache 默认安装地址为 /usr/local/apache2

7启动Apache

1、[root@ipc1 bin]# ./apachectl start

8、 测试Apache是否安装成功

浏览器输入IP地址,看到IT WORK,就算成功了

9配置PHP

1、检查是否安装了libxm

[root@localhost apache2]# rpm -qa |grep libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12

2、重新安装libxml2libxml2-devel, yum安装的时候发现新版本会提示更新,需要更新的可以更新,不要跳过就行了。

[root@localhost apache2]# yum install libxml2

[root@localhost apache2]# yum install libxml2-devel -y

3、安装完之后查找xml2-config文件是否存在

[root@localhost apache2]# find / -name "xml2-config"
/usr/bin/xml2-config

4、如果存在的话重新安装php

[root@rh-linux php-5.4.3]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php5/etc

[root@rh-linux php-5.4.3]# make

[root@rh-linux php-5.4.3]# make install

5、          配置Apachephp 的关系

6、          修改httpd.conf

httpd.conf最后加上php的安装路径PHPIniDir "/usr/local/php5"

7、          测试安装是否成功

编写success.php 文件内容为上图。

把文件拷贝到配置的文件放置的目录中/usr/local/apache2/htdocs 即为httpd.xml文件中配置的路径下即可。

重启apache  ./usr/local/apache2/bin

[root@localhost bin]# ./apachectl start

在浏览器中输入  http://IP地址/success.php

安装成功。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值