跳转到主要内容
lingfeng2310 提交于 18 December 2012
原文链接:http://drupal.org/node/7789578

建立一个本地MAMP(Mac Apache MySQL PHP)服务器的可参考说明。

设置外部服务器时,请按照以下步骤:

1,安装Drupal7.0到/users/xxx/sites/drupal,用户xxx为用户组“_www”成员,确保成员组在整个安装过程中都有写入权限。创建一个从/Library/WebServer/Documents/xxx到/Users/xxx/Sites的映射。

2,在雪豹系统Apache2中,重写权限是默认开启的。启动PHP5和虚拟主机,这个只要将/etc/apache2/httpd.conf下面几行取消注释:

#Dynamic Shared Object (DSO) Support

#LoadModule libexec/apache2/libphp5.so

#Virtual hosts (This is just a marker for what follows so you should leave the #.)

#Include /private/etc/apache2/extra/httpd-vhosts.conf

3,添加一个虚拟主机,确保在/private/etc/apache2/extra/httpd-vhosts.conf文件中至少包含下面几条语句:

<VirtualHost *:80>

DocumentRoot /Library/WebServer/Documents

ServerName localhost

<Directory /Library/WebServer/Documents>

Options FollowSymLinks Indexes MultiViews

AllowOverride All

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

4,在/Users/xxx/Sites/drupal/.htaccess文件中的代码块中添加一个重写规则:RewriteBase /drupal:

IfModule mod_rewrite.

RewriteEngine on

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a

# VirtualDocumentRoot and the rewrite rules are not working properly.

# For example if your site is at <a href="http://example.com/drupal" title="http://example.com/drupal" rel="nofollow">http://example.com/drupal</a> uncomment and

# modify the following line:

# RewriteBase /drupal

RewriteBase /xxx/drupal

# Rewrite URLs of the form & to the form index.php?q=x&.

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !=/favicon.ico<br /> RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

IfModule

5,复制/Users/xxx/Sites/drupal/sites/default文件目录为/Users/xxx/Sites/drupal/sites/localhost,并且确保这个对_www组是可写的。

6,在MySQL中手动创建一个数据库,复制/Users/xxx/Sites/drupal/sites/localhost/default.settings.php文件为/Users/xxx/Sites/drupal/sites/settings.php,并确保这个文件对_WWW组是可写的。在/Users/xxx/Sites/drupal/sites/settings.php中配置数据库如下:

$databases['default']['default'] = array(

    'driver' => 'mysql',

    'database' => 'databasename',

    'username' => 'username',

    'password' => 'password',

    'host' => 'localhost',

    'prefix' => 'main_',

    'collation' => 'utf8_general_ci',

  );

7,注意:

在雪豹系统中开启GD Library。

不同于之前版本的OS X,雪豹系统的PHP版本不需要重新编译就支持GD Library,在PHP中开启GD Library,编辑文件/etc/php.ini,将下面这行的注释(分号)删除:

;extension=php_gd2.dll

删除分号之后,重启Apache服务器,GD libraries就可以使用了。

如何重建PHP5来包含GD tools请参考这里

8,继续下一步将文件权限修改回来之后,访问http://localhost/xxx/drupal/install.php,就会出现下面运行安装脚本的页面。