lampfree小站

学习交流lamp技术,笔记记录

从0开始搭建一个lnmp环境 - 源代码安装php(4)

评论

安装php的时候确保,必要的软件已经安装。

yum install -y gcc gcc-c++ automake wget
yum install -y zlib-devel openssl-devel gd-devel
yum install -y libxml2-devel pcre-devel curl-devel

安装加密扩展

这个是可选的,如果需要加密功能这个需要安装

cd /soft
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -xzvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/lampfree/libmcrypt
 make && make install

安装php

这里有个安装顺序的问题,安装php需要和mysql结合。
所有要先安装mysql,

--with-mcrypt=/lampfree/libmcrypt   \
--with-mysqli=/usr/bin/mysql_config \
--with-mysql-sock=/var/lib/mysql/mysql.sock \

php 安装脚本

cd /soft 
wget http://hk1.php.net/get/php-7.0.6.tar.gz/from/this/mirror -O php-7.0.6.tar.gz
tar -xzvf php-7.0.6.tar.gz

cd php-7.0.6
./configure --prefix=/lampfree/php70 \
--enable-fpm \
--with-openssl \
--with-pcre-regex \
--with-zlib \
--enable-bcmath \
--with-curl \
--with-libxml-dir \
--enable-ftp \
--with-openssl-dir \
--with-gd \
--enable-mbstring \
--with-mcrypt=/lampfree/libmcrypt   \
--with-mysqli=/usr/bin/mysql_config \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-pdo-mysql \
--enable-shmop  \
--enable-zip  

make && meke install

测试

这里测试,是否可以打印出phpinfo的信息
一:添加文件 /lampfree/nginx/html/index.php
file: /lampfree/nginx/html/index.php

<?php

phpinfo();

二: 修个nginx配置文件

vi  /lampfree/nginx/conf/nginx.conf

在 server 快中添加

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;
}

表示如果遇到php文件通过 fastcgi 方式传递给 php-fpm 处理
三: 开始 php-fpm
复制文件

[root@localhost etc]# pwd
/lampfree/php70/etc
[root@localhost etc]# tree
.
├── pear.conf
├── php-fpm.conf.default
└── php-fpm.d
    └── www.conf.default

.
├── pear.conf
├── php-fpm.conf
├── php-fpm.conf.default
└── php-fpm.d
    ├── www.conf
    └── www.conf.default

执行命令, 获得一份配置文件

cp /soft/php-7.0.6/php.ini-development /etc/php.ini

开始 php-fpm

/lampfree/php70/sbin/php-fpm -c /etc/php.ini -y /lampfree/php70/etc/php-fpm.conf

让nginx重新加载配置文件

/lampfree/nginx/sbin/nginx  -s reload

通过浏览器访问看大这个图片就全部完成
phpinfo.jpg