PHP【第一篇】安装
一、准备
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
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【第一篇】安装的更多相关文章
- 【OpenCV入门指南】第一篇 安装OpenCV
		http://blog.csdn.net/morewindows/article/details/8225783/ win10下vs2015配置Opencv3.1.0过程详解(转) http://ww ... 
- 第一篇 -- 安装和配置PyQt5
		我的电脑环境是:Win10 + Python3.6.4 + JetBrains PyCharm 2017.3.2 x64 之前用tkinter写界面,现在学习如何用PyQt5写界面. 安装PyQt5: ... 
- OpenResty 安装及使用(第一篇安装)
		OpenResty搭建 1.openResty介绍 OpenResty (也称为 ngx_openresty)是一个全功能的 Web 应用服务器.它打包了标准的 Nginx 核心,很多的常用的第三方模 ... 
- Node 之 Express 学习笔记 第一篇 安装
		最近由于工作不忙,正好闲暇时间学学基于 node 的 web开发框架. 现在关于web开发框架除了Express 还有新出的 KOA以及其它一些. 但是想想还是先从 Express 入手吧.因为比较成 ... 
- NODEJS环境搭建 第一篇 安装和部署NODEJS
		一.下载安装文件 根据自己当前系统环境,下载相对应的安装文件 https://nodejs.org/en/download/ 二.双击安装 都傻瓜式的安装步骤,一步一步安装就好了. 三.检查安装结果 ... 
- Oracle学习第一篇—安装和简单语句
		一 安装 10G ----不适合Win7 Visual Machine-++++Visual Hard Disk 先安装介质(VM)---便于删除 11G-----适合Win7 1 把win64_1 ... 
- GoLang(第一篇 安装)
		golang官网:https://golang.org 中文文档:docscn.studygolang.com/doc/ 一:环境变量设置 导入环境变量GOROOT:export GOROOT=/us ... 
- 【OpenCV第一篇】安装OpenCV
		[OpenCV第一篇]安装OpenCV 本篇主要介绍如何下载OpenCV安装程序,如何在VS2008下安装配置OpenCV,文章最后还介绍了一个使用OpenCV的简单小例子. <OpenCV入门 ... 
- 分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)——第一篇
		分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)--第一篇 简介 首先简单了解一下基础概念,FastDFS是一个开源的轻量级分布式文件系统,由 ... 
- ElasticSearch入门 第一篇:Windows下安装ElasticSearch
		这是ElasticSearch 2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ... 
随机推荐
- js中replace用法
			js中replace的用法 replace方法的语法是:stringObj.replace(rgExp, replaceText) 其中stringObj是字符串(string),reExp可以是正则 ... 
- 注意EntityFramework.extended中的坑
			EntityFramework.extended 的好处就不用多说了 详情:https://github.com/loresoft/EntityFramework.Extended 但是使用时还是要注 ... 
- POJ 3083 Children of the Candy Corn 解题报告
			最短用BFS即可.关于左手走和右手走也很容易理解,走的顺序是左上右下. 值得注意的是,从起点到终点的右手走法和从终点到起点的左手走法步数是一样. 所以写一个左手走法就好了.贴代码,0MS #inclu ... 
- Azure Site Recovery:我们对于保障您的数据安全的承诺
			Anoob Backer 云 + Enterprise 项目经理  Azure Site Recovery是一个基于 Azure的全天候.易用的服务,可以安全地安排恢复操作,一旦发生灾难,即可为您 ... 
- Mac 上Dock中添加“最近打开过的项目”(Recent Applications)
			有一个特别有用的Stack,“最近打开过的项目”,建立方法如下: 1. 打开Terminal,输入以下命令 defaults write com.apple.dock persistent-other ... 
- HTML特殊字符大全
			特殊符号 命名实体 十进制编码 特殊符号 命名实体 十进制编码 ! ! " " " # # $ $ % % & & & ' ... 
- STL总结之queue, priority_queue, stack
			之所以把这三个容器放在一起,是因为他们都是容器适配器. STL中queue就是我们常用的FIFO队列,实现是一个容器适配器,这种数据结构在网络中经常使用. queue的模板声明: templa ... 
- [Irving]Sql Server 日期、时间、比较
			在sql 的数据库表里时间字段是比较全的格式:例如GetdataTime字段:2007-06-05 12:34:50. 但在前台程序里,利用日历控件,可能查询的时候是以某天来做比较,例如开始时间:20 ... 
- Error -26359: Function not allowed within a concurrent group
			Error -26359: Function not allowed within a concurrent group 疑问: 基于url录制的脚步能用检查点么? 疑问: web_set_max ... 
- Unity 时间缩放状态下的特效播放
			时间缩放状态下,比如 Time.timeScale 缩小为 0 或者 0.000001 等极小值时,若想将特效的播放速度放大相同的倍数,即修改 ParticleSystem.playbackSpeed ... 
