CentOS6.5下安装Apache2.4+PHP7
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的更多相关文章
- 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 ...
- Windows10 下安装 Apache2.4+PHP7.1+MySQL5.7
这个教程主要是分享如何快速组建WAMP开发环境,对于软件的详细配置,自行参考文档或搜索. Visual C++ Redistributable for Visual Studio 2015 下载地址: ...
- Centos7 下安装Apache2 + MySQL + PHP7
Apache 1.安装Apache yum install httpd 2.设置服务器开机自动启动Apache systemctl enable httpd.service 若要验证是否自动启动可在重 ...
- 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 ...
- centos6.3编译安装Apache2.4.3+PHP5.4.8+Mysql5.5.8
以虚拟机VirtualBox 版本是4.1.20(内存设置为512M,centos安装是文本模式下安装),全新以最小化包安装了32位的 CentOS6.3系统,作为本地web环境,上次讲了在windo ...
- 【转载】CentOS6.5_X64下安装配置MongoDB数据库
[转载]CentOS6.5_X64下安装配置MongoDB数据库 2014-05-16 10:07:09| 分类: 默认分类|举报|字号 订阅 下载LOFTER客户端 本文转载自zhm&l ...
- CentOS6.5下安装配置MySQL
CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...
- 在CentOS6.8下安装Docker
在CentOS6.8下安装Docker 一.查看系统版本 [root@localhost opt]# uname -a Linux localhost.localdomain -.el6.x86_64 ...
- coreseek/sphinx CentOS6.4下安装
一.在CentOS6.4下安装coreseek之前需要预先安装以下软件 1.打开终端 输入 su 获取管理员权限 2.输入命令 yum install make gcc g++ gcc-c++ lib ...
随机推荐
- GNU C的定义长度为0的数组
在标准C和C++中,长度为0的数组是被禁止使用的.不过在GNU C中,存在一个非常奇怪的用法,那就是长度为0的数组,比如Array[0];很多人可能觉得不可思议,长度为0的数组是没有什么意义的,不过在 ...
- Linux 添加程序图标到开始菜单中
Linux平台的Ubuntu系统中,开始菜单中的程序都在/usr/share/applications/目录下,文件格式都是xxxx.desktop ========================= ...
- elasticsearch内存优化设置
1.禁用交换分区 最简单的选项是完全禁用交换,通常elasticsearch是在框上运行的唯一服务,内存由ES_HEAP_SIZE环境变量控制,设有必要启用交换分区 linux:swapoff -a ...
- 用户登陆代码py
实现用户输入用户名和密码,当用户名为 seven 且 密码为 123 时,显示登陆成功,否则登陆失败! 实现用户输入用户名和密码,当用户名为 seven 且 密码为 123 时,显示登陆成功,否则登陆 ...
- Java中的13个原子操作类
java.util.concurrent.atomic包一共提供了13个类.属于4种类型的原子更新方式,分别是原子更新基本类型,原子更新数组,原子更新引用和原子更新属性.Atomic包里的类基本都是使 ...
- maven导出项目依赖的jar包
摘要: 在进行项目部署时,需要将maven项目所依赖的jar导出到指定目录,本文讲解如何导出项目依赖的jar包 一.导出到默认目录 targed/dependency 从Maven项目中导出项目依赖的 ...
- SpringBatch Sample (二)(CSV文件操作)
本文将通过一个完整的实例,与大家一起讨论运用Spring Batch对CSV文件的读写操作.此实例的流程是:读取一个含有四个字段的CSV文件(ID,Name,Age,Score),对读取的字段做简单的 ...
- 【转载】 pytorch自定义网络结构不进行参数初始化会怎样?
原文地址: https://blog.csdn.net/u011668104/article/details/81670544 ------------------------------------ ...
- MySQL中的视图详解
一.什么是视图? 简单来说,视图就是从一张表中导出的虚拟表.视图拥有表的结构,但是在数据库中只有视图的定义,但是没有视图中的数据. 视图是由查询语句从一张表中导出来的数据,不是一张实际的表. 二.视图 ...
- stringify在苹果电脑下的值不能为空
sessionStorage.channel = JSON.stringify( );苹果的safari不接受stringify里面为空 火桑飘零ご 2018/1/25 20:21:49 wind ...