Command Line Tips for Starter Kits
Using the Command Line to install or upgrade the Starterkit may require you to take an extra step to change and reset permissions on the sites folder and settings.php file.
DURING DRUPAL INSTALLATION:
sudo chown -R www-data sites
(gives you permission to set the permissions on the sites/default files)sudo chgrp -R webdev sites
(makes the webdev group have write access)sudo chmod -R 775 sites
(changes permissions back after install)
For Mac users - Command Line tools can be found here: ss64.com/osx/
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.
Read moreWorking with Drush on Mamp
The current version of MAMP may require some troubleshooting to get Drush to work correctly. Known issues include:
- Default use of php5.3.6 instead of php5.2.17 causes errors upon update, most commonly "Cannot redeclare class" errors. To solve, change the version of PHP in the MAMP preferences panel or add a line in your .bash_profile to tell Drush to use the right version of PHP
export DRUSH_PHP="/Applications/MAMP/bin/php/php5.2.17/bin/php". - Inability to connect to localhost MySQL via socket. Causes errors like "Error: PDO::__construct(): [2002] No such file or directory (trying
to connect via unix:///var/mysql/mysql.sock)". To solve, from within Terminal run the following commands:sudo mkdir /var/mysqlsudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
Quickly disabling and re-enabling a project with drush
To disable and re-enable a project:
drush -y dis PROJECTNAME; drush -y en PROJECTNAMEIf you have Devel installed, there is an additional command available; devel-reinstall which will disable, uninstall, and install a list of projects.
drush -y devel-reinstall PROJECTNAMEUseful 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 directoryzip -r zipfile.zip *
Unzip Contents into current directoryunzip zipfile.zip
Unzip (and extract) the tar'd, gzipped archive (tarball) Contents into current directorytar zxvf tarballfile.tar.gz
Remove a directory and its contents (Use with extra care)rm -rf directoryname
Backup Databasemysqldump dbname -uUSERNAME -pPASSWORD --host HOST > filename.sql
Restore Databasemysql -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
How to use the Command Line
Using the command line can be daunting. This set of videos walks you through the basics of using the command line, from navigating to different file paths to modifying text and moving files around.
- Why the command line can be scary, and the benefits of conquering your fear
- How to navigate file structures and stop processes on the command line
- How to edit and save text files on the command line with VIM
- How to use built-in help on the command line