安装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. CentOS启用sudo,禁用root远程登录

    CentOS默认不启用sudo,且可以直接用超级管理员身份登录服务器.ubuntu这方面做得比较好,为了安全,减小误操作带来的损失,还是推荐启用sudo. 1.添加sudo用户 执行 visudo 命 ...

  2. PHP Socket实现websocket(一)基本函数介绍

    WebSocket protocol 是HTML5一种新的协议.它实现了浏览器与服务器全双工通信(full-duplex). 一开始的握手需要借助HTTP请求完成. WebSocket是基于TCP来实 ...

  3. FineUI第十八天---表格之事件的处理

    表格之事件的处理: 1.事件参数: GridPageEventArgs:表格分页事件参数,对应onPageIndexChange事件. NewPageIndex:新页面的索引 GridSortEven ...

  4. Opencv,腐蚀,膨胀,轮廓检测,轮廓外接多边形

    //形态学腐蚀 cvErode(pDstImage,pDstImage,,); //形态学膨胀 cvDilate(pDstImage,pDstImage,,); //中值滤波 cvSmooth(pDs ...

  5. 小白死去活来的安装ros_qtc_plugin

    在距离写上一篇有关ROS的文章已经过去了很久了.在这段时间内一直在积累,盼望着能够厚积薄发,但还是被无情的社会折磨的死去活来,深深的体会到了一般学校和重点学校找工作的差别,以及用人单位的区别对待.说到 ...

  6. Python自动化之select、greenlet和gevent和事件驱动模型初探

    进程.线程和协程的区别 进程拥有自己独立的堆和栈,既不共享堆,亦不共享栈,进程由操作系统调度. 线程拥有自己独立的栈和共享的堆,共享堆,不共享栈,线程亦由操作系统调度(标准线程是的). 协程和线程一样 ...

  7. TLS 与 python thread local

    TLS 先说TLS( Thread Local Storage),wiki上是这么解释的: Thread-local storage (TLS) is a computer programming m ...

  8. ndk学习12: 线程

     

  9. ndk学习8: 编译动态库

    目录: 手工编译动态库 ndk-build编译动态库(Eclipse环境)   手工编译静态库 老规矩还是先手工操作,知其然并知其所以然   需要用到的核心命令: gcc -g -c -fpic -W ...

  10. Java拼接批量新增SQL语句

    StringBuffer addSql = new StringBuffer(1000); int batchSize = 50; int executeTime = 0; SimpleDateFor ...