Video cài đặt Drush trên Mac OS X

Video cài đặt Drush trên Mac OS X

Last weekend we made a video that shows, hopefully, how easy it is to install Drush, the fabulously powerful command line tool that can drastically speed up developing, installing and maintaining Drupal sites. If you're worried about command line, don't fret. You can type, right? Then you can do command line!

This video covers just installing Drush. It does not get into setting up a local development environment otherwise. There are far too many ways to do that to cover here (but there are some links at the bottom of the post that might help).

The video we made seems to race by in its 2-minute running time, and it may feel like the information is going by too fast. So I've posted the same info, with some more explanation, below.

The Video

The Instructions

Here's the background, step by step, for your reference.

Video: Installing Drush on Mac OS X

It really is easy. Don't let Terminal deter you!

1. Download Drush

[Update: While the video shows downloading the latest stable release, the project page now recommends you download the latest HEAD version. Update 29 March 2010: Drush 3 has reached release candidate stage, so at this point it's probably best to use the latest stable release after all. —LS]

Get it at http://drupal.org/project/drush. Drush works for every version of Drupal, so just find the latest version and download it.

Put the tarball into your working folder. Ideally this is a folder in your home directory. Some people use their "sites" folder for development. I created on my computer in my home directory a working folder called "dev".

Double-click on the tarball to open it up. When you go into the drush folder, you'll see a number of files, including the README.txt file. Read it!

2. Make Drush Executable

Now we venture into the command line. I hope that doesn't vex you, because Drush is a command line tool.

Open your Terminal. This opens up to your "home" directory, which corresponds to the Finder folder that bears your Mac username.

PINGV Creative

The path to your drush will depend upon where you put it.

You will want to type the command here:

chmod u+x /path/to/drush/drush

(replacing "/path/to/" with the actual path relative to your home directory). So in my case, with Drush residing in the "dev" folder:

chmod u+x dev/drush/drush

Now that you've made drushexecutable, you want to set things up so you actually can execute the drushcommand outside of the actual Drush folder (such as in your working folder for the site you're building). So....

3. Create an Alias

This part may seem a bit mysterious if the Terminal stuff is new to you, but it's really quite simple. We will be adding to your "bash profile" file the path to the drushcommand so that you can run the drushcommand from anywhere in your filesystem.

home folder shortcut
A handy Unix shortcut to your "home" folder is "~/". You can use that in any path designation in relation to the system root.

Find your bash profile file using the Terminal in your "home" directory.

If you're not there, go ahead and enter on the command line:

cd ~/

The bash profile files are hidden from normal view, so to see what files you have in your home directory, enter this command:

ls -a

bash profile file namesYour bash profile might be named any of these files. If you don't see any of these in your "home" folder, create one using nano. nano will create the file if it doesn't find one by that name.

You get a list of all the files in that folder. (The "hidden" files start with a dot ".") Look for one of these files:

  • .profile
  • .bash_aliases
  • .bashrc
  • .bash_profile

Any one will do, so just pick an existing file. (For me, it was .bash_profile.)

Edit the file in the nano editor, the really simple, old school text editor that comes with Unix. Just enter nano [filename]. For me, that means:

nano .bash_profile

This takes you into the editor, and might be looking at one or two lines of code. Cursor down to the end of the file and make sure you're on a new line, and add:

Replace the "/path/to/" part with the actual path relative to the system root.

alias drush='/path/to/drush/drush'

replacing the "/path/to/" part with the actual path — but this time it needs to be relative to the system root. Now, remember that shortcut to the "home" directory above? Now's the time to use that.

alias drush='~/dev/drush/drush'

Now save the file using <control>-x, y(es), <enter>. Now you're back at your Terminal prompt.

Now all you need to do is reload the updated bash profile using source [filename]. In my case:

source .bash_profile

4. Test

Yes, I know I said it was three steps. But this is testing, and you don't want to skip testing, do you? To test, simply type:

drush

You should get a long list of available Drush commands. You're done! (Or rather, now you can get started!)

Drush it!

Drush Resources

You'll want to dive in and experience Drush Power™! So here are pages you will want to explore.

  • The main Drush documentation page (bookmark this) has a list of the basic drush commands.

    Pay special attention to the examples at the bottom. I found, for example, that if a drush command wasn't working, pointing to the actual uri for that Drupal instance helped Drush find the appropriate database. Also remember that not all modules are covered in the project name. For example, CCK contains a lot of modules, so you can "dl CCK" but you cannot "en CCK".

  • Using Drush to synchronize and deploy sites looks to be one extremely powerful use case for Drush. This is amazing. Anything that makes deployment easier is a big plus in my book!
  • Drush Make, an extension to Drush that can create a ready-to-use Drupal site, pulling sources from various locations. It does this by parsing a flat text file (similar to a drupal .info file) and downloading the sources it describes. In practical terms, this means that it is possible to distribute a complicated Drupal distribution as a single text file.

More helpful references on Drush, its installation, its power, and more

Hope this is helpful!

 

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Adding a New Drupal Block Position

Thêm 1 vị trí Drupal Block với ShallowGrunge.Module

One of our students wanted to put a block position inside the red header bar. If you haven't done so already, download and install ShallowGrunge: http://drupal.org/project/shallowgrunge

Nokia N9 Preview and First Look

Nokia N9 Preview and First Look

Technology has spread its arms to endless horizons where everyday new inventions come into existence in this world.

Apple sẽ lùi ngày phát hành iTunes 11

Apple sẽ lùi ngày phát hành iTunes 11

Hôm thứ Ba (30/10), Apple cho biết iTunes 11 sẽ bị dời ngày phát hành với lí do có sự chậm trễ bất ngờ và mong muốn dịch vụ được "hoàn thiện thêm".

Công ty diệt chuột T&C

 

Diet con trung