Categories

(83)
(69)
(8)
(34)
(74)
(149)

Setting environment for Drupal projects development on the basis of Debian 6

08.07.2011
Setting environment for Drupal projects development on the basis of Debian 6
Author:

In this post, the bases of creating environment for Drupal development on the basis of Debian 6 "Squeeze" will be described. Having this, everyone will be able to practice setting OS services, develop sites not depending on online servers.

Let's decide what our web development company need for this wonderful task:

1. Installed system, in our case Debian 6 "Squeeze" (I think there is no need to go into detail on installation of this system because there are more than enough articles on this subject in web). It is assumed that you know how to create folders from console, make links and install program packages.

2. Environment for Drupal:

2.1. Web server (e.g., Apache)

2.2. PHP

2.3. Database server (e.g. MySQL, PostgreSQL)

Before starting installation, let's see if there are no updates for our system, we'll launch corresponding commands for that:

drupal@debian6:~$ sudo apt-get update
drupal@debian6:~$ sudo apt-get upgrade 

Then we install Apache, PHP.

drupal@debian6:~$ sudo apt-get install apache2 apache2-doc php5 libapache2-mod-php5 php-pear
drupal@debian6:~$ sudo apt-get install php5-curl php5-gd php5-idn php5-imagick php5-ldap php5-imap php5-memcache php5-mhash php5-mysql php5-ps php5-pspell php5-sqlite php5-suhosin php5-tidy imagemagick php5-xcache php5-xdebug php5-xmlrpc php5-xsl build-essential php5-dev bzip2

Activate rewrite module:

drupal@debian6:~$ sudo a2enmod rewrite

As Database server MySQL can be installed:

drupal@debian6:~$ sudo apt-get install mysql-server
drupal@debian6:~$ sudo apt-get install mysql-client

Or instead of MySQL, MariaDB can be installed:

drupal@debian6:~$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 1BB943DB
drupal@debian6:~$ sudo nano /etc/apt/sources.list.d/mariadb.list

And add two lines into the file

deb http://mirror.de.gsnw.de:56431/mariadb/repo/5.2/debian squeeze mai
deb-src http://mirror.de.gsnw.de:56431/mariadb/repo/5.2/debian squeeze main
drupal@debian6:~$ sudo apt-get update
drupal@debian6:~$ sudo apt-get install mariadb-server

If you don't really like working with console, you can install phpmyadmin for the work with bases:

drupal@debian6:~$ sudo apt-get install phpmyadmin

Now you can see it at http://localhost/phpmyadmin (if you work at one computer) or at http://your_ip/phpmyadmin (if environment is at a remote computer).

your_ip - is IP-address where everything is installed.

Instead of writing long name, it can be shortened from http://localhost/phpmyadmin into http://localhost/pma. You must edit configuration file for that

drupal@debian6:~$ sudo nano /etc/phpmyadmin/apache.conf

in Alias line /phpmyadmin usr/phpmyadmin change /phpmyadmin into /pma or any other convenient name, and restart apache:

drupal@debian6:~$ sudo /etc/init.d/apache2 restart

Now when everything is installed, you can start setting directories, virtual hosts and permissions for folders.

On default, we'll keep all our sites in /var/www folder, but permissions for it are only for root. Let's change them for our user:

drupal@debian6:~$ sudo chown -R drupal:drupal /var/www

To check PHP work, we'll use phpinfo

drupal@debian6:~$ sudo nano /var/www/phpinfo.php

Insert

  phpinfo();

And check its work at http://localhost/info.php

We'll change PHP settings for our work:

drupal@debian6:~$ sudo nano /etc/php5/apache2/php.ini

change parameters:
max_execution_time = 90 (script execution time in seconds)
post_max_size = 32M (maximum size that is transfered by POST requests)
upload_max_filesize = 50M (maximum filesize that can be uploaded, which is very convenient if database is imported through phpmyadmin)
To accelerate work of PHP scripts, install eAccelerator

drupal@debian6:~$ sudo apt-get install build-essential php5-dev

Create category for cache and define permissions for it:

drupal@debian6:~$ sudo mkdir -p /var/cache/eaccelerator
drupal@debian6:~$ sudo chmod 0777 /var/cache/eaccelerator

PHP 5.3 on default is installed with XCache support. For eAccelerator to work appropriately, you must move XCache from modules

drupal@debian6:~$ sudo mv /etc/php5/conf.d/xcache.ini ~/

Restart Apache2

drupal@debian6:~$ sudo /etc/init.d/apache2 restart

Check if eAccelerator is present in PHP

drupal@debian6:~$ php -v
PHP 5.3.3-7+squeeze1 with Suhosin-Patch (cli) (built: Mar 18 2011 17:22:52) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

Then we create virtualhost for our project (copy default virtualhost for your site):

drupal@debian6:~$ sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/drupal7
drupal@debian6:~$ sudo nano /etc/apache2/sites-available/drupal7

It should look the following way:

<VirtualHost *:80>
        ServerAdmin webmaster @ localhost
        ServerName drupal7.loc

        DocumentRoot /var/www/drupal7
        <Directory />
                Options FollowSymLinks
                AllowOverride All 
        </Directory>
        <Directory /var/www/drupal7/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All 
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

We enable our site (make virtualhost active):

drupal@debian6:~$ sudo a2ensite drupal7

Restart Apache2 to activate VirtualHost settings for our site.

drupal@debian6:~$ sudo /etc/init.d/apache2 restart

If you work at one computer, you can use /etc/hosts file, where you will link URL of your project to our IP.

drupal@debian6:~$ sudo nano /etc/hosts

Add a line there:

127.0.0.1 drupal7.loc

Then go to /var/www/ and unpack Drupal into a folder, drupal7 for installation. After we put http://drupal7.loc/ into address line - window of Drupal installation will be opened.

As a result, Drupal developers have an environment on which some time was spent, but now we can do our favorite business of developing projects.

6 votes, Rating: 5

Read also

1

Being involved in development process one has got to realize actions/commands for which he has not been granted enough rights or the user whose server has launched and executed Drupal, is lacking...

2

One of Drupal 7's major advantages over its precursors is its flexibility with settings and systems. Drupal developers haven't bypassed DB queries, either. In this release the latter have become...

3

Late in April of the current year Google Analytics representatives have announced in their official blog about launching of beta-testing of new interface. In this article I want to share about the...

4

If someone's likely to be challanged with the necessity to have the attached PDF document displayed on the content view ...

5

Sometimes there is a need to create autocomplete field in order to enhance usability. As worked examples of such fields w...

Subscribe to our blog updates