CentOS6.5下安装Apache2.4+PHP7

http://blog.csdn.net/along602/article/details/42695779

http://www.th7.cn/Program/php/201511/691594.shtml

http://jingyan.baidu.com/article/d2b1d10299bda55c7f37d466.html

1,准备工作,首先要下载所需软件的源码包,有如下这些:

apr-1.5.1.tar.bz2

apr-util-1.5.4.tar.bz2

pcre-8.36.tar.bz2

httpd-2.4.10.tar.bz2

php-7.0.20.tar.gz
 
把所有的源码包上传到服务器上/var/lamp目录下

cd /var/lamp

首先要安装Apache的依赖库

tar jxvf apr-1.5.1.tar.bz2

tar jxvf apr-util-1.5.4.tar.bz2

tar jxvf pcre-8.36.tar.bz2

tar jxvf httpd-2.4.10.tar.bz2

tar zxvf php-7.0.20.tar.gz

cd apr-1.5.1
./configure --prefix=/usr/local/apr
make && make install

cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

cd pcre-8.36
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install

2,安装Apache2.4
 
首先要安装Apache的依赖库
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
pcre-8.36.tar.gz
 
tar zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
make && make install
 
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
 
tar zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
 
安装PCRE的时候遇到如下错误:
You need a C++ compiler for C++ support
解决方案是:
yum install -y gcc gcc-c++
注意:这个-y千万不能少。
 
 
可以开始安装Apache了,
解压缩
cd httpd-2.4.17
./configure  --prefix=/usr/local/apache2  --with-apr=/usr/local/apr  --with-apr-util=/usr/local/apr-util  -with-pcre=/usr/local/pcre  --enable-so--enable-rewrite
make && make install

注意:--enable-so--enable-rewrite 中间不能有空格

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

service httpd start

cd /usr/local/apache2/bin

./httpd -v 出现版本号

http://www.xxx.com 访问出现

It works!

测试是否安装成功

2,安装PHP7
cd /var/lamp/php-7.0.20

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/apache2/conf --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-zip

make && make install

错误1 如果你在执行./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli --with-pdo-mysql --enable-mbstring时,出现这样的错误

configure:error:xml2-config not found.Please check your libxml2 installation.

说明需要libxml2,用yum装一下:yum -y install libxml2 libxml2-devel

装完libxml2后,就可以正常地进行php的源码安装了

错误2 解决 Cannot find OpenSSL's <evp.h>

yum install openssl openssl-devel

错误3 Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/

其实就是curl的dev包没有安装, 解决方案:yum -y install curl-devel

错误4 error: png.h not found.

yum install libpng libpng-devel

错误5 error: freetype-config not found.

yum install freetype-devel

错误6 error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum install libxslt-devel

出现

Thank you for using PHP.

config.status: creating php7.spec

就代表安装成功了。

1,在Vim中搜索”DirectoryIndex“字符串,大家可以看到已经有index.html了,在index.html后面添加你想让apache识别的DirectoryIndex

在/user/local/apache2/conf/httpd.conf配置文件中再添加一段指令:

<FilesMatch "\.ph(p[2-6]?|tml)$">

SetHandler application/x-httpd-php

</FilesMatch>

这段指令告诉apache,碰到文件名以

.php, .php2, .php3, .php4, .php5, .php6或phtml结尾的文件使用

libphp7.so模块进行解析。

其中"\.ph(p[2-6]?|tml)$"为正则表达式,你可以随意更改,只要符合PCRE正则表达式语法,都可以。

2,接下来,在Vim中搜索”DirectoryIndex“字符串,大家可以看到已经有index.html了,在index.html后面添加你想让apache识别的DirectoryIndex

<IfModule dir_module>
DirectoryIndex index.html index.php index.phtml
</IfModule>

3,修改PHP的配置文件php.ini
进入php源码目录,选择php.ini-development复制一份到/usr/local/apache2/conf,并改名为php.ini使用vi打开,查找extension_dir,修改为extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20131226",读者根据自己的PHP安装目录结构配置,目的是找到PHP的扩展库。 
查找extension=php_,去掉extension=php_curl.dll,extension=php_gd2.dll,extension=php_mbstring.dll,extension=php_mysql.dll,extension=php_mysqli.dll,extension=php_pdo_mysql.dll,extension=php_xmlrpc.dll前面 的分号。查找short_open_tag = Off把它修改成short_open_tag = On,让其支持短标签(我看注释这个默认是打开的)。
 
 
从别人的服务器上我还拷贝了如下文件放到
/usr/local/php/lib/php/extensions/no-debug-zts-20131226目录,
文件如下:
Imap.so
Mcrypt.so
Memcache.so
Openssl.so
Zip.so
 
然后在php.ini的最后增加如下配置文字:
extension=memcache.so
extension=openssl.so
extension=mcrypt.so
extension=zip.so
   
 
 
 
4,修改Apache配置文件httpd.conf相关修改以支持PHP
vi /usr/local/apache/conf/httpd.conf

Ø  添加php支持。
【添加字段一】
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
 
【添加字段二】
<FilesMatch /.php$>
SetHandler application/x-httpd-php
</FilesMatch>

Ø  添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php

Ø  3. 不显示目录结构,找到“OptionsIndexes FollowSymLinks”,修改为
Options FollowSymLinks

Ø  4. 开启Apache支持伪静态,找到“AllowOverride None”,修改为
AllowOverride All
 
重启Apache
service httpd restart
 
提醒:实在不知道怎么配置,就找个已经搭建成功的服务器把配置文件弄过来对比一下。

此时还会遇到如下报错:

httpd: Could not reliably determine the server's fully qualified domain name

解决办法:

linux : /usr/local/apache/conf

用记事本打开httpd.conf

将里面的#ServerName localhost:80注释去掉即可。

启动apache遇到错误:httpd: Could not reliably determine the server's fully qualified domain name
[root@server httpd-2.2.4]# /usr/local/apache/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
1)进入apache的安装目录:(视个人安装情况而不同) [root@server ~]# cd /usr/local/apache/conf
2)编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80

到此,整个Apache+PHP5.6的环境搭建完毕。

CentOS6.5下安装Apache2.4+PHP7的更多相关文章

  1. CentOS6.5下安装apache2.2和PHP 5.5.28

    CentOS6.5下安装apache2.2 1. 准备程序 :httpd-2.2.27.tar.gz 下载地址:http://httpd.apache.org/download.cgi#apache2 ...

  2. Windows10 下安装 Apache2.4+PHP7.1+MySQL5.7

    这个教程主要是分享如何快速组建WAMP开发环境,对于软件的详细配置,自行参考文档或搜索. Visual C++ Redistributable for Visual Studio 2015 下载地址: ...

  3. Centos7 下安装Apache2 + MySQL + PHP7

    Apache 1.安装Apache yum install httpd 2.设置服务器开机自动启动Apache systemctl enable httpd.service 若要验证是否自动启动可在重 ...

  4. CentOS6.4 下安装 Apache2.4.16

    1.准备工作 1.1.yum安装部分工具 1)yum -y install vim 2)yum -y install wget 3)yum -y install gcc 4)yum -y instal ...

  5. centos6.3编译安装Apache2.4.3+PHP5.4.8+Mysql5.5.8

    以虚拟机VirtualBox 版本是4.1.20(内存设置为512M,centos安装是文本模式下安装),全新以最小化包安装了32位的 CentOS6.3系统,作为本地web环境,上次讲了在windo ...

  6. 【转载】CentOS6.5_X64下安装配置MongoDB数据库

    [转载]CentOS6.5_X64下安装配置MongoDB数据库 2014-05-16 10:07:09|  分类: 默认分类|举报|字号 订阅      下载LOFTER客户端 本文转载自zhm&l ...

  7. CentOS6.5下安装配置MySQL

    CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...

  8. 在CentOS6.8下安装Docker

    在CentOS6.8下安装Docker 一.查看系统版本 [root@localhost opt]# uname -a Linux localhost.localdomain -.el6.x86_64 ...

  9. coreseek/sphinx CentOS6.4下安装

    一.在CentOS6.4下安装coreseek之前需要预先安装以下软件 1.打开终端 输入 su 获取管理员权限 2.输入命令 yum install make gcc g++ gcc-c++ lib ...

随机推荐

  1. .NET界面控件DevExpress发布v18.2.4|附下载

    DevExpress Universal Subscription(又名DevExpress宇宙版或DXperience Universal Suite)是全球使用广泛的.NET用户界面控件套包,De ...

  2. OpenStack平台虚拟机实例在线迁移失败问题

    一.在线迁移时提示如下的报错 二.原因分析 通过kolla-ansible部署queens版本时,因为OEM的机器设备的UUID记录的一致,导致迁移时识别的是自身机器的UUID,导致迁移失败 三.问题 ...

  3. spring源码研究1 如何导入源码

    环境 jdk8 windows8 1.下载源码 https://github.com/spring-projects/spring-framework 2.编译为eclipse项目 源码下载无法直接导 ...

  4. 循环神经网络-LSTM进阶

    基础的LSTM模型,单隐层,隐层单神经元,而实际中一般需要更为复杂的网络结构, 下面借用手写数字的经典案例构造比较复杂的LSTM模型,并用代码实现. 单隐层,隐层多神经元 # -*- coding:u ...

  5. oracle 正则表达式 匹配

    oracle 正则表达式 在实际应用中,想排除带有中文的字段值: select h.froomnumber from t_broker_house h where REGEXP_LIKE(froomn ...

  6. TransactionScop事务机制的使用

    如果在C#中使用TransactionScope类(分布式事务),则须注意如下事项:1.在项目中引用using System.Transactions命名空间(先要在添加net组件的引用); 2.具体 ...

  7. [MyBatis] MyBatis理论入门

    什么是MyBatis iBATIS提供的持久层框架包括SQL Maps和Data Access Objects(DAOs) 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. MyB ...

  8. chromium ③

    chromium源码学习笔记(1) -- 学习计划       对于c++开发者来说,chromium几乎是目前最值得学习的优秀开源代码.先看看chromium包含了多少令人激动的特性:     1, ...

  9. C#清理所有正在使用的资源

    namespace QQFrm{    partial class Form1    {        /// <summary>        /// 必需的设计器变量.        ...

  10. 如何给cbv的程序添加装饰器

    引入method_decorator模块 1,直接在类上加装饰器 @method_decorator(test,name=‘dispatch’) class Loginview(view) 2,直接在 ...