位置:首页  >   服务器运营  > liunx下php的安装

liunx下php的安装

1. 下载安装包


安装依赖


yum -y install libmcrypt-devel mhash-devel libxslt-devel \libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \krb5 krb5-devel libidn libidn-devel openssl openssl-devel

yum install openldap
yum install openldap-devel




wget http://pear.php.net/go-pear.phar





使用./configure会有的错误提示3

3.  提示libxml2  error

   安装依赖

   yum install libxml2

   yum install  libxml2-devel


   错误:

 Cannot find OpenSSL's <evp.h>

yum install openssl openssl-devel 


configure: error: Please reinstall the libcurl distribution

 yum install curl curl-devel



configure: error: png.h not found.


yum install libpng


yum install libpng-devel


configure: error: mcrypt.h not found. Please reinstall libmcrypt.


yum  install epel-release  //扩展包更新包

yum  update //更新yum源
yum install libmcrypt libmcrypt-devel mcrypt mhash  就ok了


configure: error: jpeglib.h not found.

yum install libjpeg libjpeg-devel

configure: error: freetype-config not found.

yum install freetype freetype-devel


参考:

http://blog.aboutc.net/linux/65/compile-and-install-php-on-linux



创建 www 用户

# groupadd www # useradd -g www -s /sbin/nologin -M www

编译安装

# cd /usr/local/src/php-5.6.0/ # ./configure \ --prefix=/usr/local/php56 \ --with-config-file-path=/usr/local/php56/etc \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-opcache \ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ --with-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-gettext \ --enable-mbstring \ --with-iconv \ --with-mcrypt \ --with-mhash \ --with-openssl \ --enable-bcmath \ --enable-soap \ --with-libxml-dir \ --enable-pcntl \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-sockets \ --with-curl \ --with-zlib \ --enable-zip \ --with-bz2 

参数说明:

""" 安装路径 """ --prefix=/usr/local/php56 \ """ php.ini 配置文件路径 """ --with-config-file-path=/usr/local/php56/etc \ """ 优化选项 """ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ """ 启用 opcache,默认为 ZendOptimizer+(ZendOpcache) """ --enable-opcache \ """ FPM """ --enable-fpm \ --with-fpm-user=www \ --with-fpm-group=www \ """ MySQL """ --with-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ """ 国际化与字符编码支持 """ --with-gettext \ --enable-mbstring \ --with-iconv \ """ 加密扩展 """ --with-mcrypt \ --with-mhash \ --with-openssl \ """ 数学扩展 """ --enable-bcmath \ """ Web 服务,soap 依赖 libxml """ --enable-soap \ --with-libxml-dir \ """ 进程,信号及内存 """ --enable-pcntl \ --enable-shmop \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ """ socket & curl """ --enable-sockets \ --with-curl \ """ 压缩与归档 """ --with-zlib \ --enable-zip \ --with-bz2 \ """ GNU Readline 命令行快捷键绑定 """ --with-readline

如果你的 Web Server 使用的 Apache 请添加类似:--with-apxs2=/usr/local/apache-xx/bin/apxs 参数。

# make -j8 

# make install




配置 PHP

配置文件

# cp php.ini-development /usr/local/php56/etc/php.ini

php-fpm 服务

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

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

# chmod +x /etc/init.d/php-fpm56

启动 php-fpm

# service php-fpm56 start 

Starting php-fpm done



添加 PHP 命令到环境变量

编辑 ~/.bash_profile,将:

PATH=$PATH:$HOME/bin 改为: PATH=$PATH:$HOME/bin:/usr/local/php56/bin

使 PHP 环境变量生效:

# . ~/.bash_profile

查看看 PHP 版本

# php -v PHP 5.6.0 (cli) (built: Sep 23 2014 03:44:18) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies


测试 我放置一个yaf项目后,发现不能运行报错!

SQLSTATE[HY000] [2002] No such file or directory

原因是:php.ini 安装时指定mysql.sock 没有指定

参考:http://www.cnblogs.com/AloneSword/p/3188012.html


修改 php.ini 中,所有关于 "default_socket" 的所有路径为 “/var/lib/mysql/mysqld.sock”


重启nginx



0
文章属性
精彩评论