1.获取php源码

  # cd /usr/local/src/

  # wget http://cn2.php.net/get/php-7.0.15.tar.gz/from/this/mirror

  2.解压源码包

  # tar -xf mirror

  # cd php-7.0.15

  3.根据自己需要写配置

  # ./configure --prefix=/usr/local/php --with-mysqli --with-openssl --enable-fpm --enable-sockets --enable-sysvshm  --with-mysqli --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml  --with-mhash --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl --with-pdo_mysql

  注:此过程会报错,和nginx一样缺少什么软件就安装对应的dev包,我在执行时报的错误安装了一下包,仅供参考 yum install libxml2-devel.x86_64 bzip2-devel.x86_64 libcurl-devel.x86_64 -y

  4.# make

  5.# make test

  6.# make install

  7.为php提供主配置文件

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

  8.为php-fpm提供Sysv init脚本,并将其添加至服务列表:

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

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

  # chkconfig --add php-fpm

  #chkconfig php-fpm on

  9.为php-fpm提供配置文件

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

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

  10.修改配置文件

    修改主配置文件:

      # vim /etc/php.ini

      cgi.fix_pathinfo=0

    修改php-fpm配置文件:

      # vim /usr/local/php/etc/php-fpm.conf

      开启php-fpn.conf的pid  pid=run/php-fpm.pid

    修改www的配置文件:

      # vim /usr/local/php/etc/php-fpm.d/www.conf

      将用户与组都修改为www-data用户

      user=www-data

      group=www-data

  11.修改nginx配置文件,使其将收到的php请求转发给php-fpm处理,取消PHP模块之前的注释,并修改为

    #vim /etc/nginx.conf

    location / {
      root html;
      index index.php index.html index.htm;
    }

    

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

  12.修改php.ini指定mysql的socket文件地址

    # vim /etc/my.cnf | grep socket

    会显示当前的sock文件地址 格式:socket=/var/lib/mysql/mysql.sock

    将mysql的socket地址填入php.ini

    # vim /etc/php.ini

    找到并修改为mysqli.default_socket = /var/lib/mysql/mysql.sock

  13.启动php-fpm,重新启动nginx

    # /usr/local/php/sbin/php-fpm

    # /usr/local/nginx/sbin/nginx -t

    # killall nginx

    # /usr/local/nginx/sbin/nginx

  14.创建测试页

    #rm /usr/local/nginx/html/index.html

    # vim /usr/local/nginx/html/index.php

      

<?php
$conn = new mysqli('localhost','root','此处填写MySQL-root用户的密码','mysql');
var_dump($conn);

  15.测试

    #curl http://localhost

 

												

LNMP环境搭建(三:PHP)的更多相关文章

  1. LNMP环境搭建:Nginx安装、测试与域名配置

    Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件 2.编译安装Nginx (1)安装Nginx依赖函数库pcre pcre为“perl兼容正则表达 ...

  2. LNMP环境搭建之php安装,wordpress博客搭建

    LNMP环境搭建之php安装,wordpress博客搭建 一.介绍: 1.什么是CGI CGI全称是"通用网关接口"(Common Gateway Interface),HTTP服 ...

  3. LNMP环境搭建哈哈

    经过一番折腾,终于将LNMP环境搭建完成了.本文介绍的LNMP环境是在windows的Oracle VM VirtualBox中的Centos虚拟机上搭建的,各个软件的版本为:Centos7 + Ng ...

  4. zabbix学习(一)——LNMP环境搭建及zabbix安装

    第一部分:LNMP环境搭建 一.环境说明: OS:   centos7.6_x64nginx:nginx-1.16.0php:   php-7.1.11mysql:mysql-5.6.44 zabbi ...

  5. Linux下-LNMP环境搭建博客网站(全过程)

    通常我们所说的LNMP是指一个网站基本的组织框架,即Linux系统支持,Nginx静态服务,Mysql数据库支持以及PHP动态编程语言支持.目前Mysql数据库被Oracle数据库分析公司收购,其创始 ...

  6. LNMP环境搭建

    LNMP环境搭建 Linux + Nginx + MySQL + PHP PHP是一种脚本语言,当前中国乃至世界上使用PHP语言开发的网站非常普遍 Nginx是一个web服务软件,和apache是一类 ...

  7. 阿里云(ECS)Centos服务器LNMP环境搭建

    阿里云( ECS ) Centos7 服务器 LNMP 环境搭建 前言 第一次接触阿里云是大四的时候,当时在校外公司做兼职,关于智能家居项目的,话说当时俺就只有一个月左右的 php 后台开发经验(还是 ...

  8. odoo开发环境搭建(三):安装odoo依赖的python包

    odoo开发环境搭建(三):安装odoo依赖的python包 http://www.cnblogs.com/jlzhou/p/5940815.html

  9. LNMP环境搭建——MySQL篇

    The world's most popular open source database 1.Install MySQL root@kallen:~# apt-get install mysql-s ...

  10. Ubuntu16.04 lnmp 环境搭建

    Ubuntu16.04 lnmp 环境搭建 nginx 安装 sudo apt-add-repository ppa:nginx/stablesudo apt-add-repository ppa:o ...

随机推荐

  1. 一个小时内学习SQLite数据库

    一个小时内学习SQLite数据库 2012-05-11 10:24 红薯 OSCHINA 字号:T | T SQLite 是一个开源的嵌入式关系数据库,实现自包容.零配置.支持事务的SQL数据库引擎. ...

  2. 【Mybatis】未封装返回结果的字段自己返回值的问题

    在spring boot中使用mybatis过程中,发现有个实体的时间字段未在mapper方法执行完的封装结果中进行封装,但是却有值返回. 如下展示问题: 实体如下: package com.sxd. ...

  3. python 实现创建文件夹和创建日志文件

    一.实现创建文件夹和日志 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author: nulige import os import datetime ...

  4. lua基础【三】唯一数据结构table表

    --[[ 数据结构table对象(一种动态分配的对象) lua中的表操作.table类型实现了"关联数组的". "关联数组是一种具有特殊索引方式的数组" 能够通 ...

  5. POJ 1040 Transportation

    链接:http://poj.org/problem?id=1040 Transportation Time Limit: 1000MS Memory Limit: 10000K Total Submi ...

  6. 倍福TwinCAT(贝福Beckhoff)基础教程2.2 TwinCAT常见类型使用和转换_指针

    定义pt为指向INT类型的指针,在程序中取得var_int1的地址(INT类型),然后将地址对应的数据还原给var_int2(pt^的写法)     更多教学视频和资料下载,欢迎关注以下信息: 我的优 ...

  7. 2、cas4.0 单点登录 之 cas-client

    cas4.0 单点登录 之 cas-client cas4.0 单点登录 之 https证书已经做好了证书的准备工作.如今结合cas-server来配置单点登录: 一.安装cas服务端(cas-ser ...

  8. SVN遇到Can't convert string from 'UTF-8' to native encoding(转)

    svn: Can't convert string from 'UTF-8' to native encoding: svn: platform/console-framework/portal/im ...

  9. Javascript 客户端实时显示服务器时间

    <!doctype html> <html lang="zh-cn"> <head> <meta charset="utf-8& ...

  10. mongo: 索引

    索引创建 在学习索引之前,我们先看一下,如果没有添加索引时,我们用explain()函数,查看查询计划是什么样的. 发现使用的是BasicCursor,那么就代表我们没有索引,当我们查某一个数据的时候 ...