התקנת drush

בזמן האחרון יוצא לי לכתוב יותר מדי פוסטים שקשורים ל-IT. אין מה לעשות, מתכנת PHP אמור להבין גם בסיסטם ולעבוד בסביבת לינוקס. LAMP זה LAMP.

כמתכנת דרופל, יוצא לי לעבוד עם drush לא מעט והוא הפך להיות חלק חיוני בכל קונסטלציה של שרת הפיתוח שלי. drush (הוגים אותו כ'דרש', אבל כינוי החיבה שלי אליו הוא דרוּש) הוא סקריפט קצר ב-BASH שיישום שלו מאפשר לי לבדוק, להתקין ולהפעיל דרופל ומודולים שונים שלו לפי הצורך, בקלות ויעילות הישר מה-shell של הלינוקס, בלי להתעסק עם ברדק ועם ממשק משתמש.

לחלק ממתכנתי דרופל זה יישמע כמו סיוט, למה לא להפעיל, לעדכן או לכבות מודולים באמצעות ממשק הניהול הנוח של דרופל? למי שמעדיף לעבוד עם לינוקס, drush הוא פתרון נוח ומהיר בהרבה.

ההתקנה של drush היא פשוטה ביותר. ראשית, נאתר או ניצור תיקיה מתאימה להתקנה תחת home/your_user/

אני לצורך הדוגמא מתקין את drush בתיקית


/home/ran/Desktop/drush

אני אצור את תיקית drush תחת ה-Desktop שלי ואז אשיג את הקובץ העדכני ביותר של ה-drush ואוריד אותו לתיקית home/ran/Desktop:


wget http://ftp.drupal.org/files/projects/drush-All-versions-3.0.tar.gz

לאחר מכן נפתח את הקובץ:


tar zxf drush-All-versions-3.0.tar.gz

תיווצר לנו תיקיה שנקראת drush. נכנס אל התיקיה ונוודא ש drush/. עובד (שימו לב לנקודה קו נטוי). אם עובד, אז אחלה. במידה והוא נותן לכם אזהרת PHP, התקינו את: 


sudo apt-get install php5-cli

ואחרי כן יש לרסט את ה-apache:


sudo /etc/init.d/apache2 restart

אם הכל תקין ועובד כאמור, נכנס ל-bash.rc שלנו באמצעות nano או עורך טקסט אחר:


sudo nano ~/.bashrc


ונוסיף את השורה הזו:


alias drush='/home/ran/Desktop/drush/drush'


נשמור ונצא ולאחר מכן נכתוב ב-shell את המילה bash כדי לאתחל את bash. אם יש הודעת שגיאה, תבדקו את השורה שהוספתם. האם יש בה רווחים או שהיא מוקמה במקום בעייתי?
במידה והקשתם bash ולחצתם על אנטר והכל תקין, אפשר כבר להשתמש ב-drush. הקלידו drush ואנטר, צריך לצאת לכם משהו כזה:


Execute a drush command. Run `drush help [command]` to view command-specific help.

Examples:
 drush dl cck zen                          Download CCK module and Zen theme.                  
 drush --uri=http://example.com status     Show status command for the example.com multi-site. 
 drush help --pipe                         A space delimited list of commands                  

Options:
 -r <path>, --root=<path>                  Drupal root directory to use (default: current directory)                
 -l <uri>, --uri=http://example.com        URI of the drupal site to use (only needed in multisite environments)    
 -v, --verbose                             Display extra information about the command.                             
 -d, --debug                               Display even more information, including internal messages.              
 -q, --quiet                               Hide all output                                                          
 -y, --yes                                 Assume 'yes' as answer to all prompts                                    
 -n, --no                                  Assume 'no' as answer to all prompts                                     
 -s, --simulate                            Simulate all relevant actions (don't actually change the system)         
 -i, --include                             A list of paths to search for drush commands                             
 -c, --config                              Specify a config file to use. See example.drushrc.php                    
 -u, --user                                Specify a user to login with. May be a name or a number.                 
 -b, --backend                             Hide all output and return structured data (internal use only).          
 -p, --pipe                                Emit a compact representation of the command for scripting.              
 --nocolor                                 Suppress color highlighting on log messages.                             
 --show-passwords                          Show database passwords in commands that display connection information. 
 -h, --help                                This help system.                                                        
 --php                                     The absolute path to your PHP intepreter, if not 'php' in the path.

Commands:
 cache-clear (cc)      Clear a specific cache, or all drupal caches.
 core-cli (cli)        Enter a new shell optimized for drush use.
 core-cron (cron)      Run all cron hooks.
 core-rsync (rsync)    Rsync the Drupal tree to/from another server using ssh.  Relative paths start from the Drupal root folder if a site alias is used; otherwise they start from the current working
                       directory.
 core-status (status,  Provides a birds-eye view of the current Drupal installation, if any.
 st)
 drupal-directory      Return path to a given module/theme directory. See --help for more details.
 (dd)
 help                  Print this help message. Use --filter to limit command list to one command file (e.g. --filter=pm)
 php-eval              Evaluate arbitrary php code after bootstrapping Drupal.
 php-script (scr)      Run php script(s).
 pm-disable (dis)      Disable one or more modules or themes.
 pm-download (dl)      Download core Drupal and projects like CCK, Zen, etc.
 pm-enable (en)        Enable one or more modules or themes.
 pm-info               Show info for one or more projects.
 pm-list (sm)          Show a list of available modules and themes
 pm-refresh (rf)       Refresh update status information
 pm-releases           Release information for a project
 pm-uninstall          Uninstall one or more modules.
 pm-update (up)        Update your project code and apply any database updates required (update.php)
 pm-updatecode (upc)   Update your project code
 search-index          Index the remaining search items without wiping the index.
 search-reindex        Force the search index to be rebuilt.
 search-status         Show how many items remain to be indexed out of the total.
 site-alias (sa)       Print site alias records for all known site aliases and local sites.
 site-install (si)     Install Drupal along with modules/themes/configuration using the specified install profile.
 site-upgrade (sup)    Run a major version upgrade for Drupal core and contrib modules.
 sql-cli (sqlc)        Open a SQL command-line interface using Drupal's credentials.
 sql-conf              Print database connection details using print_r().
 sql-connect           A string for connecting to the DB.
 sql-dump              Exports the Drupal DB as SQL using mysqldump.
 sql-query (sqlq)      Execute a query against the site database.
 sql-sync              Copy source database to target database using rsync.
 updatedb (updb)       Execute the update.php process from the command line
 variable-delete       Delete a variable.
 (vdel)
 variable-get (vget)   Get a list of some or all site variables and values.
 variable-set (vset)   Set a variable.
 watchdog-delete       Delete watchdog messages.
 (wd-del, wd-delete)
 watchdog-list         Show available message types and severity levels. A prompt will ask for a choice to show watchdog messages.
 (wd-list)
 watchdog-show         Show watchdog messages.
 (wd-show, ws)

אלו גם ההסברים הפשוטים לשימוש ב-drush. כלי חשוב ונחמד לכל מי שמפתח על דרופל.

פוסטים נוספים שכדאי לקרוא

פתרונות ומאמרים על פיתוח אינטרנט

עבודה עם GPT למתכנתים

אני עובד עם GPT כמה חודשים טובים באופן צמוד. הוא כלי חזק וכדאי ממש להשתמש בו, אבל יש לו גם חסרונות ומגבלות שכדאי להכיר.

מיקרו בקרים

בית חכם עם ESPHome ו Home Assistant

הסבר על הום אסיסטנט, מערכת הקוד הפתוח לבית חכם ואיך לחבר אליה מיקרובקרים.

תמונת תצוגה של מנעול על מחשב
פתרונות ומאמרים על פיתוח אינטרנט

הגנה מפני XSS עם Trusted Types

תכונה ב-CSP שמאפשרת מניעה כמעט הרמטית להתקפות XSS שכל מפתח ווב צריך להכיר וכדאי שיכיר.

גלילה לראש העמוד