Home > php教程 > php手册 > body text

ubuntu下安装php5+pdo

WBOY
Release: 2016-06-13 10:59:34
Original
933 people have browsed it

  这几天尝试把工作机迁到ubuntu上来做开发,系统安装好之后的首要任务是安装php+mysql的开发环境. 我打算直接安装php5, pdo_mysql, 下面是安装过程的记录

  首先我直接用apt-get安装了apache2,php5,pear以及mysql5, 为了方便后续的安装,还加上了make和libmysqlclient

sudo apt-get install apache2-mpm-prefork

sudo apt-get install php5

sudo apt-get install php5-dev

sudo apt-get install php5-pear

sudo apt-get install mysql-server-5.0

sudo apt-get install make

sudo apt-get install libmysqlclient15-dev

  pdo在ubuntu的apt里头似乎还找不到安装源,所以通过pecl来安装这个扩展,非常简单 —- 如果海底光纤能连通的话:

pecl install pdo

增加一行:

extension=pdo.so

到文件:

/etc/php/apache2/php.ini

/etc/php/cli/php.ini

  接下来安装pdo_mysql碰到一些问题, 直接跑pecl install pecl_mysql会出现一些错误,搜索了一下发现是pecl本身的问题,下面是个比较简单的解决办法:

wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

tar xzvf PDO_MYSQL-1.0.2.tgz

cd PDO_MYSQL-1.0.2

注释掉configure里头判断是否已经安装pdo扩展的代码片段,继续跑:

phpize

./configure

make

make install

然后再次添加下面一行到前面提到的两个php.ini

extension=pdo_mysql.so

重启apache之后, php5 + pdo_mysql就在ubuntu上安装好了, documentroot是/var/www

后记

更简单的解决办法是运行:

PHP_PDO_SHARED=1 pecl install pdo_mysql


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!