linux 安装apache 2.4.9+php 7.0.28

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.gz
tar -xf curl-7.59.0.tar.gz
cd curl-7.59.0
./configure
make && make install
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.3.tar.gz
tar -xf libmcrypt-2.5.3.tar.gz
cd libmcrypt-2.5.3
./configure
make && make install

wget http://mirrors.shu.edu.cn/apache//apr/apr-1.6.3.tar.gz
mkdir /usr/local/apr
tar -xf apr-1.6.3.tar.gz
cd apr-1.6.3
./configure --prefix= /usr/local/apr
make && make install
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
mkdir /usr/local/apr-util
tar -xf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix= /usr/local/apr-util
make && make install

安装apache
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.29.tar.gz
tar -xf httpd-2.4.29.tar.gz
mv httpd-2.4.29 httpd
cd httpd
./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-so --enable-deflate --enable-expires --enable-headers --enable-ssl --enable-rewrite --enable-mpms-shared=all --with-mpm=prefork --enable-mods-shared=most

make && make install

安装php

wget http://cn2.php.net/distributions/php-7.0.28.tar.gz
tar -xf php-7.0.28.tar.gz
mv php-7.0.28 php
cd php
./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs --enable-pdo --with-pdo-mysql --with-mysql-sock --enable-xml --with-libxml-dir --enable-sockets --with-curl --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-mcrypt --with-openssl --with-mhash --enable-zip --enable-mbstring --enable-mbregex --with-iconv --enable-static

make && make install

修改配置:
修改apache httpd.conf
在195行去除“#” 修改为:ServerName localhost:80
在253行中添加index.php
DirectoryIndex index.php index.html
在390行后面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

配置php 首页index.php
在/usr/local/apache2/htdocs 中创建index.php
vim index.php
将以下内容输入文件中
<?php
phpinfio();
?>
保存退出。
启动httpd服务
/usr/local/apache2/bin/apachectl start

PHP就配置好了。

以上是关于linux 安装apache 2.4.9+php 7.0.28的主要内容,如果未能解决你的问题,请参考以下文章

Apache 与 php的环境搭建

LAMP+LNMPApache(httpd)概述与安装实践

WampServer 2.5 64位 WampServer是Apache+PHP+Mysql 集成环境

linux下apache解析不了php文件

Linux编译安装Apache+PHP

Apache/2.4.9启动错误:AH01630: client denied by server configuration