php 编译安装

  • 下载源码
  • 安装
  • 安装后配置

下载源码

php下载地址:http://php.net/downloads.php

php-7.1.11.tar.bz2

安装

安装依赖包

yum install -y epel-release bzip2
yum install -y libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

编译参数

./configure \
--prefix=/usr/local/php-7.1.11 \
--with-config-file-path=/usr/local/php-7.1.11/etc \
--enable-fpm \
--enable-exif \
--enable-sockets \
--enable-bcmath \
--enable-mbstring \
--enable-pcntl \
--enable-calendar \
--enable-opcache \
--enable-zip \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=/usr/bin/mysql_config \
--with-pdo-mysql \
--enable-mysqlnd \
--with-zlib \
--with-gd \
--with-png-dir \
--with-jpeg-dir \
--with-gettext \
--with-freetype-dir \
--with-mcrypt \
--with-openssl \
--with-curl \ make
make install

安装后配置

创建安装目录链接文件

ln -s /usr/local/php-7.1.11 /usr/local/php

创建配置文件链接目录

ln -s /usr/local/php/etc /etc/php
\cp /usr/local/src/php-7.1.11/php.ini-production /usr/local/php/etc/

编辑配置文件

cp /usr/local/php-<old-version>/etc/php.ini /usr/local/php/etc/   # 升级
cp /usr/local/php-<old-version>/etc/php-fpm.conf /usr/local/php/etc/ # 升级 cd /usr/local/php/etc/
cp php.ini-production php.ini
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf vim php-fpm.conf pid = /var/run/php-fpm.pid
error_log = /var/log/php-fpm.log

配置启动项

ln -s /usr/local/php/sbin/* /usr/sbin/
ln -s /usr/local/php/bin/* /usr/bin/
php -v
php-config vim /usr/lib/systemd/system/php-fpm.service [Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target [Service]
Type=simple
PIDFile=/var/run/php-fpm.pid
ExecStart=/bin/nice --10 /usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php/php-fpm.conf -c /etc/php/php.ini -R
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target 或者
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target [Service]
Type=simple
PIDFile=/var/run/php-fpm.pid
Environment="basedir=/usr/local/php"
ExecStart=/bin/nice --10 ${basedir}/sbin/php-fpm --nodaemonize --fpm-config ${basedir}/etc/php-fpm.conf -c ${basedir}/etc/php.ini -R
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill $MAINPID
[Install]
WantedBy=multi-user.target

启动 php-fpm

systemctl start php-fpm
ps -ef|grep php-fpm
systemctl enable php-fpm

测试

vim /etc/nginx/nginx.conf  # 在nginx的配置文件中设置支持php

location / {
root html;
index index.html index.htm index.php;
} 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;
} cd /usr/local/nginx/html vim index.php <?php
echo "test page for php";
phpinfo();
?> systemctl restart nginx # 重启nginx服务 浏览器中访问 IP/index.php

php 安装结束,安装后还需要优化。

升级php版本:

ln -s /usr/local/php-<version>  /usr/local/php   # 把新版本的安装目录链接到 php 上
\cp -r /usr/local/php-<old-version>/etc/* /usr/local/php/etc/ # 把旧版本的php配置文件拷贝到新版本的相应目录 php -v # 查看是否配置好php的链接
php-config systemctl restart php-fpm # 重启php-fpm 访问测试页面

有疑惑之处请发邮件到下面的邮箱。

2017-11-6 by achxku@163.com

php 编译安装指导的更多相关文章

  1. zabbix 编译安装指导

    zabbix 编译安装 下载 安装 安装后的配置 下载源码包 zabbix官网:https://www.zabbix.com/ zabbix下载:https://www.zabbix.com/down ...

  2. nginx-1.12.2编译安装指导

    nginx-1.12.2编译安装 下载源码包 安装 安装后配置 下载源码包 下载地址:http://nginx.org/en/download.html nginx-1.12.2:http://ngi ...

  3. windows下Bullet 2.82编译安装(Bullet Physics开发环境配置)

    平台:Win7,VS2010 1. Bullet库的组织 下图是Bullet_User_Manual中的截图: 从中可见,Bullet的LinearMath(线性数学模块),其上是BulletColl ...

  4. VLC编译问题

    在Ubuntu下编译VLC源代码生成的VLC无法播放Youtube视频(比如https://www.youtube.com/watch?v=mDp-ABzpRX8) 错误提示如下: zlf@ubunt ...

  5. 【转】Windows下使用VS2008编译OpenCV 2.1 添加Intel TBB和Python支持

    Windows下使用VS2008编译OpenCV2.1 添加Intel TBB和Python支持 步骤: 1.仔细阅读OpenCV官网上的InstallGuide:http://opencv.will ...

  6. win7下从ruby源代码编译安装

    工作中需要在c++代码中嵌入ruby c api,然而在vs工程中编译失败,所以现在通过手动从源代码编译ruby寻找原因(之前使用rubyinstaller安装).   先从官网下载ruby 2.4. ...

  7. centos 编译lantrn

    github上的安装指导: Custom fork of Go is currently required. We'll eventually switch to Go 1.7 which suppo ...

  8. 编译wxWidgets —— windows、vc71、bcc32、MinGW与命令行

    编译wxWidgets —— windows.vc71.bcc32.MinGW与命令行 http://www.diybl.com/course/3_program/vc/vc_js/20071226/ ...

  9. 【视频开发】【计算机视觉】doppia编译之一:前言及安装CUDA

    最近做一个"高清视频人流量检测"的项目,由于对实时性要求较高,我们需要较快的检测速度.在搜索茫茫"论"海后,我在"The Fastest Deform ...

随机推荐

  1. .net mvc 框架实现后台管理系统 2

    layui 数据表格 返回格式: var json = new { code = 0, count = pagers.totalRows, msg = "", data =null ...

  2. redis之常用Set和ZSet命令

    redis五种数据类型:String,Hash,List,Set,ZSet.五种数据类型各有优点,各司其职.最后两种数据类型Set和ZSet基本上是一种,ZSet就是给Set加了个排序而已(相当于加了 ...

  3. LINUX下用PHPIZE安装PHP GD扩展

    环境:LNMP in centOS 6.4. linux下PHP的扩展可以用phpize的方法,比较简单地进行启用. 以下以PHP-GD2 库安装为例子. sudo yum install php-g ...

  4. 在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误的解决办法

    问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open()处. 但是 ...

  5. MongoDB安装为windows服务

    MongoDB 下载 下载地址:http://www.mongodb.org/downloads 下载安装完成之后 第一步 创建D:\Program Files\mongodb\data 目录第二步 ...

  6. docker基本命令日志

    docker run - Run a command in a new container 启动一个新的容器,一般在docker pull之后首次运行此image -i 保持stdout打开 -t 打 ...

  7. mc03_IntelliJ IDEA配置github

    配置本地git仓库 首先配置一个本地的git仓库,熟悉一下git上传文件到github的过程,具体操作参考 mc02_配置本地git仓库并上传到github IntelliJ IDEA与github的 ...

  8. Jenkins遇到哪些坑~

    1Jenkins关闭和重启实现方式. 1.关闭Jenkins ​ 只需要在访问jenkins服务器的网址url地址后加上exit.例如我jenkins的地址http://localhost:8080/ ...

  9. SpringBoot初始教程之Servlet、Filter、Listener配置

    1.介绍通过之前的文章来看,SpringBoot涵盖了很多配置,但是往往一些配置是采用原生的Servlet进行的,但是在SpringBoot中不需要配置web.xml的 因为有可能打包之后是一个jar ...

  10. 百度Echart 地图

    使用百度地图做一个全国地图数据分析的功能,如下图 代码 <%@ Page Language="C#" AutoEventWireup="true" Cod ...