安装php之前,要先安装几个

1.下载php源码:http://cn2.php.net/distributions/php-7.0.6.tar.gz。

2.然后使用命令:tar -zxvf php-7.0.6.tar.gz,进行解压。

3.使用php时还要先安装几个其他的东西,否则安装会出错,或者不生成php.so扩展文件,

  先从ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz下载这个插件,注意不要下载最新版本除非需要,版本越新需要的依赖越多,下载完成后使用tar解压,

  执行1../configure,2.make,3.make install ,三个命令来编译安装这个东西。

  然后检查是否安装了httpd_devel,如果没有安装,执行yum install httpd-devel,进行安装,如果不安装的话,后期不会生成.so的扩展文件。

4.进入解压完的php文件,然后根据自己的需要,来配置./configure的参数

  

./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-pdo-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-fpm \
--without-gdbm \
--enable-opcache=no \
--disable-fileinfo

  注意,每个参数都可能会有依赖,比如:--with-zlib \ --enable-zip,是需要事先安装对应文件的,如果不需要,可以不指定对应参数,最好指定的编译参数是:--prefix --with-mysqli --with-apxs2 。

  编译完成如果么有错误,那就执行 make && make install .如果报错,看是否是缺少什么依赖,在重新编译前,先执行:make clean,否则可能会产生错误,错误信息:***lo' is not a valid libtool object。

5.复制配置文件:php的推荐配置文件,已经存在于源码文件中了,使用find命令查找一下,一般是两个:php.ini-production,php.ini-development,至于将那个当配置使用,就看自己的了。

6.根据安装位置,将对应的php文件位置添加到PATH中,文件位置:/etc/profile,在最后添加:

  PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin -- 注意添加的不是php可执行的本身,而是上一级目录,否则不能使用,
  export PATH

  最后执行source /etc/profile 重新加载配置文件,然后echo $PATH,来看路径是否添加进了环境变量。

7.以上修改完毕之后应该是已经可以在本地执行php文件了,如果不能,则是有问题,要查看是php文件,还是path路径配置问题。

8.配置httpd.conf文件,

  在配置文件中搜素:  AddType 关键字,在其后面追加下面三行,如果不追加,httpd会直接打印php文件内容,不会调用php执行。

AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php .phtml .php3
    AddType application/x-httpd-php-source .phps

 接下来添加默认搜索php文件,在配置文件中查找DirectoryIndex 关键字,如果后面没有index.php,就在后面追加index.php,这样httpd才能默认访问php文件

接下来添加对php的支持,搜索LoadModule关键字,添加:LoadModule php7_module modules/libphp7.so,如果后期出现不能加载libphp7.so,则表示php编译有问题,最大可能就是没添加--with-apxs2参数,或者设置错误,需要重编php源码文件,直到能    在系统内搜索到libphp7.so为止。

 在httpd.conf内最好手动执行php的配置文件位置,方式为PHPIniDir "/usr/local/php7/bin",这样能保证重启httpd服务的时候,重新装载对的php配置。

 以上完成之后应该是配置完毕,找到index.html正确位置,添加index.php文件并将其他命名为index的文件改成其他名字,否则默认不会加载index.php,在index.php中添加代码

 

<?php
phpinfo();
?>

然后重启httpd服务器,使用IP访问测试,如果不行,先检查防火墙是否关闭,或者开放了指定的端口。

测试端口是否打开:firewall-cmd --query-port=80/tcp

打开指定端口:firewall-cmd --add-port=80/tcp

 或者直接关闭防火墙:

  systemctl start firewalld.service#启动firewall
  systemctl stop firewalld.service#停止firewall
  systemctl disable firewalld.service#禁止firewall开机启动

编译过程中可能出现的错误和解决办法:

运行之后遇到的问题:

error 1

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

(看提示就明白 是一个lib库没装  先用 yum search 名字 看是否能搜到名字 ,找到名字后 把软件包 开发包装上)

解决办法

yum install libxml2-devel.x86_64

error 2

checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>

这是ssl没装

解决办法

yum  install  openssl.x86_64 openssl-devel.x86_64 -y

error 3

checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

这是bzip2软件包没有安装

解决办法

yum install bzip2-devel.x86_64 -y

error 4

configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

curl和curl库文件没有安装

解决办法

yum install libcurl.x86_64 libcurl-devel.x86_64 -y

error 5

checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found

GD库没有安装

解决办法

yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y

error 6

checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

libmcrypt库没有安装 ,要是不能用yun安装的话  就要去下载个gz包 自己编译安装

(编译安装  ./configure --piefix=/usr/local/libmcrypt   make && make install)

要是错误里面含有mysql的  那是mysql-devel 没有安装

centos7 php7 httpd的更多相关文章

  1. centos7启动httpd服务失败:Job for httpd.service failed because the control process exited with error code.

    centos7启动httpd命令有两个可以用 service httpd start    systemctl start httpd.service 如果出现如下报错 Job for httpd.s ...

  2. centos7 + php7 lamp全套最新版本配置,还有mongodb和redis

    我是个懒人,能yum就yum啦 所有软件的版本一直会升级,注意自己当时的版本是不是已经更新了. 首先装centos7 如果你忘了设置swap分区,下面的文章可以教你怎么补一个上去: http://ww ...

  3. centos7 apache httpd安装和配置django项目

    一.安装httpd服务 apache在centos7中是Apache HTTP server.如下对httpd的解释就是Apache HTTP Server.所以想安装apache其实是要安装http ...

  4. php7 httpd 2.4 编译

    1.获取源码httpd-2.4.23.tar.gz   php-7.1.0.tar.gz,安装顺序必须是先安装http然后php,lnmp同理   2.安装编译环境和php.httpd依赖包,红色字体 ...

  5. centos7安装httpd和php

    centos7许多命令都变了,又要重新记了. centos7默认安装了httpd吧?记不清了,看一下: rpm -qa |grep httpd 没有的话,安装一下吧. yum -y install h ...

  6. CentOS7配置httpd虚拟主机

    本实验旨在CentOS7系统中,httpd-2.4配置两台虚拟主机,主要有以下要求: (1) 提供两个基于名称的虚拟主机: www1.stuX.com,页面文件目录为/web/vhosts/www1: ...

  7. CentOS7使用httpd apache 和firewalld打开关闭防火墙与端口

    Centos7 使用systemctl 工具操作命令 systemctl 是Centos7的服务管理工具中的主要工具 ,它融合之前service和chkconfig的功能于一体 一.httpd的设置 ...

  8. centos7+php7 swoole 安装

    下载 swoole 首先下载swoole的源码包,这个操作很简单,没有太多说的. wget -c https://github.com/swoole/swoole-src/archive/v2.0.6 ...

  9. 安装最新LAMP环境(CentOS7+PHP7.1.5+Mysql5.7)

    安装Apache&Nginx ①.升级一下yum源(不是必须的),升级会花点时间,需要选择的地方都选择都输入“y”即可 yum update ②. 安装Apache yum list |gre ...

随机推荐

  1. oracle数据表创建分区与查询

    场景: 遇到1亿数据量的数据需要根据用户名做些数据统计分析,想直接做些聚合计算基本没可能,于是打算先根据日期按照年月创建分区,然后对各个分区分别进行统计,最后汇总结果. 有两种方法,分别是手工设置分区 ...

  2. I’ve seen the world,lit it up as my stage now

    I've seen the world,lit it up as my stage now 阅尽繁华 点亮红尘做舞台 Channeling angels in,the new age now 粉末登场 ...

  3. PHP 暂停函数 sleep() 与 usleep() 的区别

    在PHP中暂停代码执行一定时间,有两个函数可以实现,一个是sleep(),另一个是usleep(),它们参数都是一个整数值.sleep()是暂停多少秒,usleep()是暂停多少微秒. 注意:usle ...

  4. js null和undefined

    在JavaScript开发中,被人问到:null与undefined到底有啥区别? 一时间不好回答,特别是undefined,因为这涉及到undefined的实现原理. 总所周知:null == un ...

  5. 传统BIOS+UEFI 系统引导修复

    一.    去网上下载一款pe软件:BIOS+UEFI引导修复工具这个软件支持传统bios和最新的UEFI引导(1)进入PE环境(win也可以,不过引导损坏一般不能进win),打开软件         ...

  6. mysql连表更新

    1.需求 有2张表,a表和b表,要把b表的name数据复制到a表中,当2表的id字段一样的时候 UPDATE A a, B b SET a.name = b.my_name WHERE a.id = ...

  7. 如何用C语言编写病毒‘

    怎样用C语言编写病毒在分析病毒机理的基础上,用C语言写了一个小病毒作为实例,用TURBOC2.0实现.[Abstract] This paper introduce the charateristic ...

  8. phpcms模板标签整理

    {template "content","header"} 调用根目录下phpcms\template\content\header文件 {CHARSET} 字 ...

  9. 一个简单的任务执行时间监视器 StopWatch

    有时我们在做开发的时候需要记录每个任务执行时间,或者记录一段代码执行时间,最简单的方法就是打印当前时间与执行完时间的差值,然后这样如果执行大量测试的话就很麻烦,并且不直观, 如果想对执行的时间做进一步 ...

  10. Git对象模型

    原文:http://gitbook.liuhui998.com/1_2.html 一.SHA 在git中,所有用来表示项目历史信息的文件,是通过一个40个字符的(40-digit)"对象名& ...