Advanced debugging of Drupal core using the command line (strace & tcpdump)

Basics

Debugging of Drupal was never easy, until you know the right tools and how to use them.

There are plenty of alternative debugging methods using some popular PHP libraries XDebug, XHProf, NuSphere PhpED, etc. and also most of the IDE have already built-in step-by-step debugger.

Useful Unix/Linux Commands for Drupal

Following are some useful Unix/Linux commands which are helpful if you are dealing with large sites (files and db size). I find these really handy when moving sites from one server to other, taking backups of Files, Database etc.

Note: To get access to the Unix command line, you will need an SSH client (e.g. Putty). You can also use WinSCP if you are not comfortable with Command line. WinSCP has a feature to enter custom commands using its interface.

Please add other command-line commands that you use while setting up, developing and managing your Drupal sites.

Zip Contents of current directory
zip -r zipfile.zip *

Unzip Contents into current directory
unzip zipfile.zip

Unzip (and extract) the tar'd, gzipped archive (tarball) Contents into current directory
tar zxvf  tarballfile.tar.gz

Remove a directory and its contents (Use with extra care)
rm -rf directoryname

Backup Database
mysqldump dbname -uUSERNAME -pPASSWORD --host HOST > filename.sql

Restore Database
mysql -u root -p[root_password] [database_name] < dumpfilename.sql

Copy all files / directories from one server to other (Both servers should have SSH Support)
rsync -avz --progress username@servername:sourcefolder destinationfolder

Linux Memcached daemon, PHP PECL, Drupal Memcache & localized UNIX sockets

This information enhances the documentation for the Drupal Memcache module. The Drupal configuration on this page is for Drupal 6, while the other information below is Drupal version agnostic. For Drupal 7 sites on Ubuntu 12.04 you may want to see this post.

Local multi-site installation of Drupal 7 on Linux

Drupal allows you to run multiple sites from a single Drupal code installation -- each with its own modules, content, theme, etc. For instance, you can run:

  • Multiple sites on your local computer
  • Multiple domains in a single hosting account
  • Multiple sub-domains
  • Multiple sub-directory sites

For a live multi-site installation, see Multisites Using Drupal 7.

This page describes one way to run multiple test sites on your local computer with Drupal 7 on Ubuntu 10.10, Ubuntu 11.04 and Mandriva 2010.2. But the method probably works with little modifications for other distributions. Purposedly, we only present one way to do that, in details, and we try to explain a bit what we're doing. We're not sure whether this procedure contains mistakes or not, and we think it probably contains useless things.

Note: if you are creating multiple sites, it is desirable to make a list of the desired sites before reading through these instructions completely. Some steps can be done in bulk to save time.

Quick install for developers (command line)

This page provides a summary of the command line instructions for installing Drupal on a typical UNIX/Linux web server. Every step contains a link to more detailed installation instructions where you also can find information about installing Drupal on other systems.

If you have problems, read Troubleshooting common problems.

Read more about system requirements (among which detailed PHP-settings and browser requirements).

Download and extract files

Download Drupal from http://drupal.org/project/drupal and extract the download file to a folder on your hard drive. (Replace the 'xx' in drupal-x.x.tar.gz with the actual version you've downloaded.)

wget http://drupal.org/files/projects/drupal-x.x.tar.gz
tar -zxvf drupal-x.x.tar.gz

Move the files to a directory within your web server's document root or your public HTML directory using the following command, substituting drupal-x.x with the actual version number. (On many *nix computers the path from the server's root will be /var/www/.)

mv drupal-x.x /var/www/

Multi-site on Linux

Software installed:

  • Drupal 6
  • Apache 1.3
  • Red Hat 6.1 (Although other distributions will work)
  • PHP5
  • PostgreSQL 7.4

The process:

(You may get more specific explanation in your Linux distribution documentation. https://help.ubuntu.com/community/Drupal
http://wiki.mandriva.com/en/Local_multi-site_installation_of_Drupal
etc.)

  1. Install the Drupal core download from Drupal.org.
  2. Install default Drupal site. I created mine with a "dummyUSER" user and "dummyDB" database with Drupal code in apache/htdocs/drupal
  3. Once you have this working then create a new dir "example1.com" directly under "sites" dir.
    mkdir sites/example1.com
    cp -R sites/default/*  sites/example1.com/
  4. Create a new database "example1DB" and new user "example1USER" in database.
  5. Edit the sites/example1.com/settings.php and change the following:
    • $db_url = 'pgsql://dummyUSER:dummyPSSWDl@localhost/dummyDB';
      to $db_url = 'pgsql://example1USER:example1PSSWDl@localhost/example1DB';
    • (this step is optional, normally Drupal will recognise the base url automatically):
      # $base_url = 'http://www.example.com';
      to $base_url = 'http://www.example1.com'; (Remove the '#' [comment])

Pages

Subscribe with RSS Subscribe to RSS - linux