版本:php5.6.4 x86_64

centos 6.6 x86_64

安装php之所以难,是因为要安装的扩展多,依赖关系复杂。

安装前的准备:

先看你想要安装哪些扩展。需要哪些包。下载地址:http://pan.baidu.com/s/1kTn7VQB

-rw-r--r--.   root root    Jun    curl-7.19..tar.gz
-rw-r--r--. root root Jun freetype-2.3..tar.gz
-rw-r--r--. root root Nov gd-2.0..tar.gz
-rw-r--r--. root root Jun GD-2.44.tar.gz-rw-r--r--. root root Jun jpegsrc.v8d.tar.gz
-rw-r--r--. root root Jun libgd-2.1.-rc2.tar.gz
-rw-r--r--. root root Jun libmcrypt-2.5..tar.gz
-rw-r--r--. root root Jun libpng-1.4..tar.gz
-rw-r--r--. root root Jun mcrypt-2.6..tar.gz
-rw-r--r--. root root Jun mhash-0.9.9.9.tar.bz2-rw-r--r--. root root Dec ncurses-5.6.tar.gz
-rw-r--r--. root root May perl-5.18..tar.gz-rw-r--r--. root root Jun zlib-1.2..tar.gz

再看看配置项:

./configure --prefix=/usr/local/php --with-config-file-path=/etc  --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm  --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

可以看出我需要的功能有,gd库,mysql,mysqli,pdo,fpm,curl,mbstring。

可能新手会很困惑,php怎么和mysql结合,这里要说一下,php只需要安装上mysql的扩展(mysql,mysqli,pdo-mysql),php程序连接mysql的时候,会自动到对应host的端口连接mysql,只要mysql服务在监听就没有问题。

/etc/my.cnf配置

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links= [mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid [client]
socket=/var/lib/mysql/mysql.sock

将上面所列出的包,依次安装上。

然后再./configure php

yum install libxml2 libxml2-devel
yum install bzip2 bzip2-devel
找不到 gd.h。
gdlib-config --all
实际上找不到gd.h是因为没有安装下面两个包。
yum install libXpm
yum install libXpm-devel
安装完,配置gd库。
perl ./Makefile.PL
cd libgd-2.1.-rc2
./configure --with-xpm=/usr/lib
中间会显示gd支持的特性。
make
make install
cd GD-2.44
perl ./Makefile.PL
make&&make install
./configure --prefix=/usr/local/php --with-config-file-path=/etc  --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm  --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd 
    make
make install
php
/usr/local/sbin/php-fpm -h
/usr/local/php/sbin/php-fpm -h
ls /usr/local/php/php/
ls /usr/local/php/
ls
cp php.ini-development /usr/local/php/php/php.ini
ls /usr/local/php/php/
find / -name php-fpm.conf.default
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin/
php-fpm start
php-fpm
vim /usr/local/php/php/php.ini

至此全部安装完毕。

  ls
./configure --help
./configure --help |grep mysqli
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd yum install libxml2 libxml2-devel
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
yum install BZip2
yum list |grep bzip2
yum install bzip2 bzip2-devel
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
ls /usr/local |grep gd
ls /usr/local/
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
ls /usr/local
ls /usr/local/lib
find / -name gd.h
./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fastcgi --enable-safe-mode --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
vim README.md
ls
vim INSTALL
make
ls /usr/local/
ls /usr/local/lib
find / |grep gd$
cd /usr/share/locale/gd/
ls
cd /root/Downloads/
ls
cd extended/
ls
cd GD-2.44
ls
vim README
find / |grep bin/gd
/usr/sbin/gdm
/usr/sbin/gdm --help
/usr/sbin/gdm --version
find / |grep bin/gd$
gd_info();
gd_info() ;
gd_info
gdlib-config
gdlib-config all
gdlib-config --all
gdbus
gdm
gdm --help
gdm-binary
gdm-binary --help
gdcmpgif
gdlib-config
gdlib-config --libs
gdlib-config --revision
gdlib-config --features
yum install libXpm
yum install libXpm-devel
gdlib-config --features
ls
./perl Makefile.PL
vim README
perl ./Makefile.PL
perl ./Makefile.PL -h
perl ./Makefile.PL
make
make install
gdlib-config
perl ./Makefile.PL --help
perl ./Makefile.PL -h
perl ./Makefile.PL ?
perl ./Makefile.PL --with-xpm=/usr/local/lib
vim README
cd ..
ls
cd libgd-2.1.-rc2
ls
./configure --with-xpm=/usr/lib
make
cd ..
ls
cd libgd-2.1.-rc2
make install
cd ..
cd GD-2.44
perl ./Makefile.PL
make&&make install
cd ..
cd php-5.6. ./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd=/usr/local/gd2/ --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd find / |grep gd.h
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-zlib --with-bz2 --with-freetype-dir --enable-mbstring --with-mysql=/usr/local/mysql/ --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-sockets --enable-gd-native-ttf --with-curl=/usr/local/curl --enable-bcmath --with-mcrypt --enable-fpm --with-mysql --with-iconv --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd make
make install
php
/usr/local/sbin/php-fpm -h
/usr/local/php/sbin/php-fpm -h
ls /usr/local/php/php/
ls /usr/local/php/
ls
cp php.ini-development /usr/local/php/php/php.ini
ls /usr/local/php/php/
find / -name php-fpm.conf.default
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/php-fpm /usr/local/bin/
php-fpm start
php-fpm
vim /usr/local/php/php/php.ini
vim /usr/local/nginx/conf/nginx.conf
/usr/local/nginx/ -s stop
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
service mysqld start
php-fpm
cd /usr/local/nginx/html/
ls
vim index.php
/usr/local/mysql/bin/mysql -uroot -p
vim index.php
vim /usr/local/php/php/php.ini
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
find /usr/ -name php-fpm.conf
vim /usr/local/php/etc/php-fpm.conf
pkill php-fpm
/usr/local/bin/php-fpm
cat /etc/passwd |grep www
vim /usr/local/php/etc/php-fpm.conf
/usr/local/bin/php-fpm
pkill php-fpm
/usr/local/bin/php-fpm
cat /etc/passwd
groupadd nginx
useradd -r -g nginx nginx
vim /usr/local/php/etc/php-fpm.conf
/usr/local/bin/php-fpm
vim /usr/local/php/etc/php-fpm.conf
/usr/local/bin/php-fpm
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
ls
cd ..
ls -l
chmod -R ./html/
ps -ef |grep php
/usr/local/mysql/bin/mysql -hlocalhost -uroot -p
ls
vim html/index.php
/usr/local/mysql/bin/mysql -uroot -p -hlocalhost
history

安装中用过的所有命令:

可能发生的错误:

configure: error: Please reinstall the BZip2 distribution

yum install bzip2 bzip2-devel

yum install -y libmcrypt libmcrypt-devel

configure:error: *** libmcrypt was not found

为了的到mcrypt.so库文件,先后安装编译了mhash和libmcrypt, 但是到最后编译mcrypt时报错:

configure: error: *** libmcrypt was not found

[root@localhost] # export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
再次编译

http://www.linuxidc.com/Linux/2009-03/18739.htm

http://www.it165.net/os/html/201304/4868.html

 安装gd的时候,会报这个错误 “usr/local/src/php-5.5.6/ext/gd/gd.c:57:22: error: X11/xpm.h: No such file or directory make: *** [ext/gd/gd.lo] Error 1”

yum install libXpm-dev libXpm

在配置gd2的时候多加一条 --with-xpm=/usr/lib
./configure 的时候 会发现
"Support for Xpm library : yes"这一项,说明配置成功。

php支持 mysqli,pdo-mysql

mysqlnd(专门为php写的),libmysqlclient(用c连接数据库用的,搞到php上来了)

http://php.net/manual/en/ref.pdo-mysql.php

nginx 发生permission deny

去看看php-fpm的用户配置,nginx的用户配置

当连接数据库的时候,我遇到这个问题了。后来发现,写127.0.0.1就可以连接,写localhost就不可以连接。mysql版本是 5.6.
create user 'root'@'localhost'的时候也有问题。总之搞不懂。
有人说和selinux有关。
http://blog.sina.com.cn/s/blog_a0d5a7f10101dzbc.html

lnmp环境的操作部分:

安装php+nginx:http://www.cnblogs.com/simpman/p/4151662.html

安装mysql:http://www.cnblogs.com/simpman/p/4192942.html

安装php:http://www.cnblogs.com/simpman/p/4196051.html

lnmp环境的理论部分:

FastCgi与PHP-fpm关系[转] 读完本文瞬间明朗了很多 : http://www.cnblogs.com/simpman/p/4151639.html

epoll和select区别:http://www.cnblogs.com/simpman/p/4150005.html

扩展下载包:http://pan.baidu.com/s/1kTn7VQB

pycurl版本低:http://www.fireinfo.cn/content-11-63668-1.html

lnmp安装--php安装的更多相关文章

  1. LNMP笔记:安装 Xcache 缓存扩展,降低服务器负载

    LNMP笔记:安装 Xcache 缓存扩展,降低服务器负载 2014/11/27 教程笔记 4,743 14     WordPress 精品主机推荐:恒创主机 | 阿里云(本站目前所用云主机) 倡萌 ...

  2. lnmp环境里安装mssql及mssql的php扩展

    小活中用到mssql,于是在自己lnmp环境中安装各mssql数据库 步骤如下: 源码编译安装 (1)下载freetds-stable-0.91源码:http://download.csdn.net/ ...

  3. lnmp环境一键安装

    lnmp一键安装命令: wget -c http://soft.vpser.net/lnmp/lnmp1.5.tar.gz && tar zxf lnmp1.5.tar.gz & ...

  4. centos lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress 安装phpmyadmin 定时备份mysql两种方法 第二十五节课

    centos  lamp/lnmp阶段复习 以后搬迁discuz论坛不需要重新安装,只需修改配置文件即可 安装wordpress  安装phpmyadmin  定时备份mysql两种方法  第二十五节 ...

  5. LNMP源码安装脚本

    LNMP安装脚本,脚本环境   #LNMP环境搭建centos6.8 2.6.32-696.28.1.el6.x86_64  nginx:1.12.2   mysql:5.6.36  PHP:5.5. ...

  6. LNMP+Zabbix的安装与部署

    LNMP+Zabbix的安装与部署 一.Zabbix简介 1.zabbix是一个基于WEB界面的,并提供分布式系统监视以及网络监视功能的企业级的开源解决方案. zabbix能监视各种网络参数,保证服务 ...

  7. Bitnami LNMP集成包安装简单总结

    前言发送图文消息时间点,访问量大,请求并发多,业务web机处理不过来,新增加了2台web机应对.搞过Linux软件安装的都知道,各种库的依赖会把人搞崩溃,尤其是服务器不能访问外网的情况下,会非常的蛋疼 ...

  8. linux lnmp环境下 安装apache教程

    linux lnmp环境下 安装apache教程 源码安装 apr ,apr-util 安装apache要用<pre>wget http://mirrors.cnnic.cn/apache ...

  9. Centos7之LNMP环境编译安装

    Centos7之LNMP环境编译安装 一.系统环境准备 注:安装时间过长,只做参考!!!1.系统信息 [root@localhost ~]# uname -r 3.10.0-957.el7.x86_6 ...

  10. 部署 LNMP(源码安装版本)shell脚本

    #!/bin/bash # 一键部署 LNMP(源码安装版本) menu() { clear echo " ##############‐‐‐‐Menu‐‐‐‐##############& ...

随机推荐

  1. MyISAM表锁

    MyISAM存储引擎只支持表锁,这也是MySQL开始几个版本中唯一支持的锁类型.随着应用对事务完整性和并发性 要求的不断提高,MySQL才开始开发基于事务的存储引擎,后来慢慢出现了支持页锁的BDB存储 ...

  2. Cent OS安装TL-WN725N 2.0 USB驱动

    TP Link官方没有提供TL-WN725N 2.0的Linux驱动下载,折腾了我半天,试了各种方法.也有一部分原因是因为这机器还不能联网,导致有一些驱动因为缺少依赖并不成功安装. 后来终于在gith ...

  3. Helpers\Request

    Helpers\Request The Helpers\Request class is used for detecting the type of request and retrieving t ...

  4. Linux命令之hwclock

    转载:http://codingstandards.iteye.com/blog/804830 用途说明 hwclock命令,与clock命令是同一个命令,主要用来查询和设置硬件时钟(query an ...

  5. cvSaveImage的第三个参数

    http://stackoverflow.com/questions/801054/opencv-cvsaveimage-jpeg-compression-factor   #define CV_IM ...

  6. 转....导入excel错误:外部表不是预期的格式 解决方案

    环境:win7+iis7+Office2007 在asp.net网站中导出Excel文件后,再把文件导入到数据库中. 读取Excel文件时,打开连接出错. 错误为:外部表不是预期的格式 解决:检查了一 ...

  7. dotnetbar 的BalloonTip的用法

    ‘设置提示标题 tip.SetBalloonCaption(txt_ID, "提示") ’设置显示的控件 和显示内容文本 tip.SetBalloonText(txt_ID, &q ...

  8. OC7_目录操作

    // // main.m // OC7_目录操作 // // Created by zhangxueming on 15/6/19. // Copyright (c) 2015年 zhangxuemi ...

  9. Git 的简单使用

    一直在使用Git,仅限于简单的使用,但还是记不住几个简单.在这边总结一下,加深印象,也方便查找. 安装Git 平常主要在windows和ubuntu上工作,就以windows为例,Linux和Mac平 ...

  10. 插件笔记——dataTables使用说明

    jquery DataTables中文使用说明 出处:http://blog.vunso.com/201405/jquery-datatables%E4%B8%AD%E6%96%87%E4%BD%BF ...