版本: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 
View Code

相关文章:

  • 2022-01-15
  • 2021-06-12
  • 2022-01-09
  • 2021-10-20
  • 2021-08-16
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2021-08-12
  • 2021-09-01
  • 2021-10-18
  • 2022-02-09
  • 2021-05-02
相关资源
相似解决方案