Debian下Apache 2 Mysql 5 Php 5安装配置

安装AMP
apt-get install apache2 mysql-server php5 php5-mysql5

配置 Apache2 默认站点
vi /etc/apache2/sites-enabled/000-default

加入一行
RedirectMatch ^/$ /apache2-default/

试验这一步不需要

修改 Apache2 主配置
vi /etc/apache2/apache2.conf

要改为:
Include module configuration:
Include /etc/apache2/mods-enabled/*.load Include /etc/apache2/mods-enabled/*.conf

还有:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

重新启动 Apache2
/etc/init.d/apache2 reload

现在要配置 PHP 5
vi /etc/php5/apache2/php.ini

Php5 默认已经不支持 Mysql,为了打开支持,要修改

extension=mysql.so

设置 Mysql 根密码
默认安装的 Mysql,其 root 用户没有密码,实在危险,我们为他加一个密码。
mysqladmin -uroot password ‘abc123’

其中abc123就是你的密码。

当然你也可以用下面的命令来设置密码:
mysql -u root mysql
mysql> update user set password=password(‘pass’) where user=’root’;

为将要架设的站点建一个库及其用户
mysql -u root -p mysql
mysql> create database drupal;
mysql> use drupal;
mysql> grant all on drupal.* to drupal_user@localhost;
mysql> use mysql;
Database changed
mysql> update user set password=password(‘pass’) where user = ‘drupal_user’;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>q;
mysqladmin reload

2 thoughts on “Debian下Apache 2 Mysql 5 Php 5安装配置”

Leave a Reply

Your email address will not be published. Required fields are marked *