lnmp安装--php安装

版本:php5.6.4 x86_64

centos 6.6 x86_64

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

安装前的准备:

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

-rw-r--r--.  1 root root   3001938 Jun 15  2013 curl-7.19.6.tar.gz
-rw-r--r--.  1 root root   1775673 Jun 17  2013 freetype-2.3.5.tar.gz
-rw-r--r--.  1 root root    587617 Nov  3  2004 gd-2.0.33.tar.gz
-rw-r--r--.  1 root root    258396 Jun 15  2013 GD-2.44.tar.gz-rw-r--r--.  1 root root    991456 Jun 15  2013 jpegsrc.v8d.tar.gz
-rw-r--r--.  1 root root   2353373 Jun 17  2013 libgd-2.1.0-rc2.tar.gz
-rw-r--r--.  1 root root   1335178 Jun 15  2013 libmcrypt-2.5.8.tar.gz
-rw-r--r--.  1 root root    837439 Jun 15  2013 libpng-1.4.12.tar.gz
-rw-r--r--.  1 root root    471915 Jun 15  2013 mcrypt-2.6.8.tar.gz
-rw-r--r--.  1 root root    655906 Jun 15  2013 mhash-0.9.9.9.tar.bz2-rw-r--r--.  1 root root   2402592 Dec 23  2006 ncurses-5.6.tar.gz
-rw-r--r--.  1 root root  17323206 May 18  2013 perl-5.18.0.tar.gz-rw-r--r--.  1 root root    560351 Jun 15  2013 zlib-1.2.7.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=0

[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.0-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 

  754  make
  755  make install
  756  php
  757  /usr/local/sbin/php-fpm -h
  758  /usr/local/php/sbin/php-fpm -h
  759  ls /usr/local/php/php/
  760  ls /usr/local/php/
  761  ls
  762  cp php.ini-development  /usr/local/php/php/php.ini
  763  ls /usr/local/php/php/
  764  find / -name php-fpm.conf.default
  765  cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
  766  cp sapi/fpm/php-fpm /usr/local/bin/
  767  php-fpm start
  768  php-fpm
  769  vim /usr/local/php/php/php.ini 

至此全部安装完毕。

663  ls
  664  ./configure --help
  665  ./configure --help |grep mysqli
  666  ./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

  667  yum install libxml2 libxml2-devel
  668  ./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
  669  yum install BZip2
  670  yum list |grep bzip2
  671  yum install bzip2 bzip2-devel
  672  ./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
  673  ls /usr/local |grep gd
  674  ls /usr/local/
  675  ./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
  676  ls /usr/local
  677  ls /usr/local/lib
  678  find / -name gd.h
  679  ./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
  680  ./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
  681  vim README.md
  682  ls
  683  vim INSTALL
  684  make
  685  ls /usr/local/
  686  ls /usr/local/lib
  687  find / |grep gd$
  688  cd /usr/share/locale/gd/
  689  ls
  690  cd /root/Downloads/
  691  ls
  692  cd extended/
  693  ls
  694  cd GD-2.44
  695  ls
  696  vim README
  697  find / |grep bin/gd
  698  /usr/sbin/gdm
  699  /usr/sbin/gdm --help
  700  /usr/sbin/gdm --version
  701  find / |grep bin/gd$
  702  gd_info();
  703  gd_info() ;
  704  gd_info
  705  gdlib-config
  706  gdlib-config  all
  707  gdlib-config  --all
  708  gdbus
  709  gdm
  710  gdm --help
  711  gdm-binary
  712  gdm-binary --help
  713  gdcmpgif
  714  gdlib-config
  715  gdlib-config  --libs
  716  gdlib-config  --revision
  717  gdlib-config --features
  718  yum install libXpm
  719  yum install libXpm-devel
  720  gdlib-config --features
  721  ls
  722  ./perl Makefile.PL
  723  vim README
  724  perl ./Makefile.PL
  725  perl ./Makefile.PL -h
  726  perl ./Makefile.PL
  727  make
  728  make install
  729  gdlib-config
  730  perl ./Makefile.PL  --help
  731  perl ./Makefile.PL  -h
  732  perl ./Makefile.PL ?
  733  perl ./Makefile.PL  --with-xpm=/usr/local/lib
  734  vim README
  735  cd ..
  736  ls
  737  cd libgd-2.1.0-rc2
  738  ls
  739  ./configure --with-xpm=/usr/lib
  740  make
  741  cd ..
  742  ls
  743  cd libgd-2.1.0-rc2
  744  make install
  745  cd ..
  746  cd GD-2.44
  747  perl ./Makefile.PL
  748  make&&make install
  749  cd ..
  750  cd php-5.6.4

  751  ./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

  752  find / |grep gd.h
  753  ./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 

  754  make
  755  make install
  756  php
  757  /usr/local/sbin/php-fpm -h
  758  /usr/local/php/sbin/php-fpm -h
  759  ls /usr/local/php/php/
  760  ls /usr/local/php/
  761  ls
  762  cp php.ini-development  /usr/local/php/php/php.ini
  763  ls /usr/local/php/php/
  764  find / -name php-fpm.conf.default
  765  cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf
  766  cp sapi/fpm/php-fpm /usr/local/bin/
  767  php-fpm start
  768  php-fpm
  769  vim /usr/local/php/php/php.ini
  770  vim /usr/local/nginx/conf/nginx.conf
  771  /usr/local/nginx/ -s stop
  772  /usr/local/nginx/sbin/nginx -s stop
  773  /usr/local/nginx/sbin/nginx
  774  service mysqld start
  775  php-fpm
  776  cd /usr/local/nginx/html/
  777  ls
  778  vim index.php
  779  /usr/local/mysql/bin/mysql -uroot -p
  780  vim index.php
  781  vim /usr/local/php/php/php.ini
  782  /usr/local/nginx/sbin/nginx -s stop
  783  /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
  784  find /usr/ -name php-fpm.conf
  785  vim /usr/local/php/etc/php-fpm.conf
  786  pkill php-fpm
  787  /usr/local/bin/php-fpm
  788  cat /etc/passwd |grep www
  789  vim /usr/local/php/etc/php-fpm.conf
  790  /usr/local/bin/php-fpm
  791  pkill php-fpm
  792  /usr/local/bin/php-fpm
  793  cat /etc/passwd
  794  groupadd nginx
  795  useradd -r -g nginx nginx
  796  vim /usr/local/php/etc/php-fpm.conf
  797  /usr/local/bin/php-fpm
  798  vim /usr/local/php/etc/php-fpm.conf
  799  /usr/local/bin/php-fpm
  800  /usr/local/nginx/sbin/nginx -s stop
  801  /usr/local/nginx/sbin/nginx
  802  ls
  803  cd ..
  804  ls -l
  805  chmod -R 777 ./html/
  806  ps -ef |grep php
  807  /usr/local/mysql/bin/mysql -hlocalhost -uroot -p
  808  ls
  809  vim html/index.php
  810  /usr/local/mysql/bin/mysql -uroot -p -hlocalhost
  811  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

[[email protected]] # 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

时间: 2024-08-08 09:40:48

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

lnmp源码安装-脚本执行

lnmp 源码安装- 脚本执行 源码包版本: nginx1.9 mysql5.6.4 php5.6 使用: 将lnmp.tar.gz 解压至 根目录下,进入/lnmp/install/目录下,执行install.sh脚本即可.选择性安装! 安装过程中会有些警告信息显示,不影响. 整合包地址:http://pan.baidu.com/s/1dFp7gqP =======================代码============================= #!/bin/bash #####

LNMP 1.3安装

安装步骤:1.使用putty或类似的SSH工具登陆VPS或服务器: 登陆后运行:screen -S lnmp 如果提示screen: command not found 命令不存在可以执行:yum install screen 或 apt-get install screen安装,详细内容参考screen教程. 2.下载并安装LNMP一键安装包: 您可以选择使用下载版(推荐国外或者美国VPS使用)或者完整版(推荐国内VPS使用),两者没什么区别,只是完整版把一些需要的源码文件预先放到安装包里.

LNMP之 nginx 安装&启动

[[email protected] ~]# cd /usr/local/src/ [[email protected] src]# wget http://nginx.org/download/nginx-1.10.2.tar.gz [[email protected] src]# tar zxvf nginx-1.10.2.tar.gz [[email protected] src]# cd nginx-1.10.2/ [[email protected] nginx-1.10.2]# ./

LNMP环境的安装

lnmp环境的安装 1.对静态网页的支持比较好 2.配置简单 3.性能,比apache高3倍以上 4.支持更大的并发连接数 安装前准备 关闭防火墙chkconfig iptables off 关闭selinux chkconfig selinux off 1.安装pcre(支持正则表达式) 直接使用yum安装 yum -y install pcre-devel-7.8-6.el6.i686.rpm 如图所示表示安装成功 2.安装zlib支持压缩 yum -y install zlib-devel

LNMP环境编译安装

安装nginx [[email protected] src]# tar -xf nginx-1.6.2.tar.gz [[email protected] src]# ls nginx-1.6.2  nginx-1.6.2.tar.gz [[email protected] nginx-1.6.2]# [[email protected] nginx-1.6.2]# useradd -s /sbin/nologin -M nginx [[email protected] nginx-1.6.2

基于CentOS6.5环境之下的LNMP之编译安装PHP5.5.30

LNMP之编译安装PHP5.5.30 1.编译前操作: 1.1.netstat -tulnp | egrep "80|3306" tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      25392/nginx          tcp        0      0 :::3306                     :::*                   

基于CentOS6.5环境之下的LNMP之编译安装Nginx1.8.0 stable(稳定版)

LNMP之编译安装Nginx1.8.0 stable(稳定版) 1.yum安装nginx所欲要的生存环境,也就是库文件 yum -y install make gcc gcc-c++ glibc glibc-devel automake autoconf libtool make 2.给nginx添加系统用户 useradd -s /sbin/nologin -M -r nginx 3.解压安装nginx1.8.0 tar xf nginx-1.8.0.tar.gz  cd nginx-1.8.

LNMP 源码安装 超详细笔记记录 PHP7 MariaDB 10.1.12

LNMP 源码安装 超详细笔记记录 php 7.04 版本 mariaDB  10.1.12 版本 首先安装nginx 一般编译nginx时,都要先安装pcre.zlib等外部支持程序,然后编译安装nginx时指定这些外部支持程序的位置,这样nginx在每次启动的时候,就会去动态加载这些东西了. 下面介绍的是另一种方式,即将这些程序编译到nginx里面去,这样nginx启动时就不会采用动态加载的方式去load.从古谱中可获知,这种方式会比动态加载有更高的效率. 首先 安装 yum install

Bitnami LNMP集成包安装简单总结

前言发送图文消息时间点,访问量大,请求并发多,业务web机处理不过来,新增加了2台web机应对.搞过Linux软件安装的都知道,各种库的依赖会把人搞崩溃,尤其是服务器不能访问外网的情况下,会非常的蛋疼.以前安装LNMP开发环境都是单个分别源码编译安装,安装过程因环境的问题,会碰到各种奇奇怪怪的问题,解决这些问题需要花些力气.以前只知道Windows才有集成开发包,真是井底之蛙!来到新东家之后,才知道Linux也有这样的集成包,线上web机都是使用集成包安装的,已经跑了几年,一直都很稳定.使用集成

LNMP --------PHP软件安装

LNMP PHP软件安装 1.1 解决PHP软件的依赖关系 yum install zlib-devel libxml2-devel libjpeg-devellibjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devellibcurl-devel libxslt-devel libxslt-devel -y 1.1.1 libiconv软件安装 mkdir -p /home/oldboy/tools cd /hom