一、准备

1、环境

系统平台:Red Hat Enterprise Linux Server release 7.3 (Maipo)

内核版本:3.10.0-514.el7.x86_64

2、下载安装包

http://php.net/downloads.php

3、安装相关依赖

# yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel

三、安装

1、解压

# tar zxvf php-7.1.0.tar.gz

2、编译

# cd php-7.1.0

./configure \
--prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc/ \
--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 \
--with-zlib-dir \
--with-mhash \
--with-mcrypt \
--with-openssl-dir \
--with-jpeg-dir \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-gd-jis-conv \
--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

可能出现的错误:

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决方法:安装 libmcrypt

地址:https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download

再编译后出现以下错误:

configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

# vi /etc/ld.so.conf.d/local.conf

添加以下语句

/usr/local/lib

# ldconfig

再执行configure,编译通过

问题内容:

checking size of off_t... 0
configure: error: off_t undefined; check your library configuration

解决方式:yum install libzip

4、安装

# make

# make install

5、测试是否安装成功

查看php版本

# /usr/local/php7/bin/php -v

显示版本信息,证明已安装成功

四、配置

1、配置php

1)配置php.ini

php.ini-development 适合开发测试,如本地测试环境, php.ini-production 拥有较高的安全性设定,适合服务器上线运营当产品。一般修改php.ini-production为php.ini,安全性更高,确保测试环境(本地)与正式环境(线上)一致。

# cd php-7.1.0

# cp php.ini-production /usr/local/php/etc/php.ini

2)配置fpm

# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

注意:php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置

# cp php-7.1.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# chmod +x /etc/init.d/php-fpm

# chkconfig --add php-fpm

3)启动命令

/etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status|configtest}

启动

#  /etc/init.d/php-fpm start

重启

# killall php-fpm
# /etc/init.d/php-fpm start

或者

/etc/init.d/php-fpm restart

2、配置apache,使其支持php

apache是把php作为自己的模块来调用的

1)配置 httpd.conf

# vi /usr/local/apache/conf/httpd.conf
 
找到 AddType application/x-gzip .gz .tgz 在其下添加如下内容

AddType application/x-httpd-php .php (.前面有空格)

AddType application/x-httpd-php-source .phps (.前面有空格)

在最后添加如下配置

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

2)编写

写一个php测试页info.php,放到 /usr/local/apache/htdocs 目录

 <?php
phpinfo();
?>

3)重启apache

# /usr/local/apache/bin/apachectl -k restart

4)测试

3、配置nginx,使其支持php

Nginx是以fastcgi的方式结合php的,可以理解为nginx代理了php的fastcgi

1)配置

location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
include fastcgi_params;
}

2)编写php代码

写一个php测试页info.php,放到apache/htdocs目录

1 <?php
2 phpinfo();
3 ?>

3)重新加载nginx配置

# /usr/local/nginx/sbin/nginx -s reload

4)测试

PHP【第一篇】安装的更多相关文章

  1. 【OpenCV入门指南】第一篇 安装OpenCV

    http://blog.csdn.net/morewindows/article/details/8225783/ win10下vs2015配置Opencv3.1.0过程详解(转) http://ww ...

  2. 第一篇 -- 安装和配置PyQt5

    我的电脑环境是:Win10 + Python3.6.4 + JetBrains PyCharm 2017.3.2 x64 之前用tkinter写界面,现在学习如何用PyQt5写界面. 安装PyQt5: ...

  3. OpenResty 安装及使用(第一篇安装)

    OpenResty搭建 1.openResty介绍 OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器.它打包了标准的 Nginx 核心,很多的常用的第三方模 ...

  4. Node 之 Express 学习笔记 第一篇 安装

    最近由于工作不忙,正好闲暇时间学学基于 node 的 web开发框架. 现在关于web开发框架除了Express 还有新出的 KOA以及其它一些. 但是想想还是先从 Express 入手吧.因为比较成 ...

  5. NODEJS环境搭建 第一篇 安装和部署NODEJS

    一.下载安装文件 根据自己当前系统环境,下载相对应的安装文件 https://nodejs.org/en/download/ 二.双击安装 都傻瓜式的安装步骤,一步一步安装就好了. 三.检查安装结果 ...

  6. Oracle学习第一篇—安装和简单语句

    一 安装  10G ----不适合Win7 Visual Machine-++++Visual Hard Disk 先安装介质(VM)---便于删除 11G-----适合Win7 1 把win64_1 ...

  7. GoLang(第一篇 安装)

    golang官网:https://golang.org 中文文档:docscn.studygolang.com/doc/ 一:环境变量设置 导入环境变量GOROOT:export GOROOT=/us ...

  8. 【OpenCV第一篇】安装OpenCV

    [OpenCV第一篇]安装OpenCV 本篇主要介绍如何下载OpenCV安装程序,如何在VS2008下安装配置OpenCV,文章最后还介绍了一个使用OpenCV的简单小例子. <OpenCV入门 ...

  9. 分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)——第一篇

    分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)--第一篇 简介 首先简单了解一下基础概念,FastDFS是一个开源的轻量级分布式文件系统,由 ...

  10. ElasticSearch入门 第一篇:Windows下安装ElasticSearch

    这是ElasticSearch 2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...

随机推荐

  1. Spring顶级项目以及Spring cloud组件

    作为java的屌丝,基本上跟上spring屌丝的步伐,也就跟上了主流技术. spring 顶级项目: Spring IO platform:用于系统部署,是可集成的,构建现代化应用的版本平台,具体来说 ...

  2. 关于标准库中的ptr_fun/binary_function/bind1st/bind2nd

    http://www.cnblogs.com/shootingstars/archive/2008/11/14/860042.html 以前使用bind1st以及bind2nd很少,后来发现这两个函数 ...

  3. Sublime Text个性化设置

    个性化格式化代码快捷键 其余快捷键设置方法类似,但注意不要与软件自带快捷键冲突 选择Preferences,点击Key Bingdings - User 在打开的文件中添加,其中ctrl+alt+sp ...

  4. new Option及用法

    op.sclassnumber.options.add(new  Option(secondMenuClassNumber[0]+":"+secondMenuText[0]),se ...

  5. apache开源项目--JMeter

    JMeter是Apache组织的开放源代码项目,它是功能和性能测试的工具,100%的用java实现.

  6. aspx页面记住密码

    界面 点击登录按钮的代码 protected void btnLogin_Click(object sender, EventArgs e) { if (remember_long.Checked) ...

  7. MySql定位执行效率较低的SQL语句

    MySQL能够记录执行时间超过参数 long_query_time 设置值的SQL语句,默认是不记录的. 获得初始锁定的时间不算作执行时间.mysqld在SQL执行完和所有的锁都被释放后才写入日志.且 ...

  8. Phonegap3.4 环境搭建及新建项目

    一.环境准备 1.到这里安装Node.js. 2.到这里下载Adroid ADT Bundle for Windows,下载后解压,我的放在:F:\MobileDev\adt-bundle-windo ...

  9. 决策树及其python实现

    剪枝 由于悲观错误剪枝 PEP (Pessimistic Error Pruning).代价-复杂度剪枝 CCP (Cost-Complexity Pruning).基于错误剪枝 EBP (Error ...

  10. 动态加载JS脚本的4种方法

    实现OPOA(One Page One Application)时,必须使用动态加载js. 也就是在用户选择某个菜单项后,再动态加载对应的全部js到客户端. 动态加载js的情况很多啊,比如解决ajax ...