Home > Backend Development > PHP Tutorial > ubuntu php环境搭建

ubuntu php环境搭建

WBOY
Release: 2016-06-20 12:32:49
Original
1008 people have browsed it

1.安装apache

sudo apt-get install apache2

修改默认的网站根目录的路径Apache的第一个配置文件apache2.conf的路径

/etc/apache2/apache2.conf

<Directory /var/www/>
Copy after login

Apache的第二个配置文件000-default.conf的路径

/etc/apache2/sites-available/000-default.conf

修改路径为/var/www/

DocumentRoot /var/www/html
Copy after login

2.安装php5

sudo apt-get install php5

3.安装pdo mysqlPDO(PHP Data Object) 是PHP 5新出来的数据库处理方式,由于php的许可与myslq的许可冲突,PHP的后续版本可能不再捆绑mysql。那么php_mysql.dll可能也不在默认支持。pdo属于pecl.php.net的项目,可以用pear安装,先安装php-pear

apt-get install php-pearsudo apt-get install php5-devsudo apt-get install libmysqlclient15-dev

然后可以安装pdo了

pecl search pdosudo pecl install pdosudo pecl install pdo_mysql

此时会报错如下:

以上表示在pear中找不到pdo_mysql 驱动,需要重新安装php5-mysql

sudo apt-get install php5-mysql

安装成功后,运行正常。虽然我们好像已经在apt安装过该php5-mysql,但是这里还是需要再安装一遍最后,修改

/etc/php5/apache2/php.ini

添加代码

extension=pdo.soextension=pdo_mysql.so
Copy after login

这样就可以通过php5来连接mysql了

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template