Good day!
Lately, more and more often, the choice of a platform for client projects falls on
everyone’s favorite Drupal 7. In this connection, one has to repeat the same series of soil preparation operations for a future website almost every day:
1) Upload Drupal 7.x to the server via FTP
2) Creating a database
3) Installing Drupal via
www.domain.ru/install.php4) Installation of all necessary modules by their URL
5) Adding Russian and updating all translations
All this takes a significant amount of time and as a result, it was decided to simplify this process by installing Drupal completely via the command line.
To do this, we use such a wonderful tool like Drush.
Drush is a site management tool for Drupal from the command line.
The installation process of this tool will not be disassembled, since there is more than enough information on the network, and for any axis. It is enough to google something like "
drush install centos ".
After successful installation of Drush, go to the root directory of the project (something like /var/www/domain.ru/).
')
1) First we need to download the current version of Drupal:
drush dl drupal
After a successful download, you will find a new directory ./drupal-7.x (instead of x, there will be an assembly version). However, we need the CMS files to be in the current directory, so we will execute 3 more commands:
mv ./drupal-7.x/* .
mv ./drupal-7.x/.htaccess .
rm ./drupal-7.x
2) The files are in place - now we install Drupal with the
si (site-install) command.
drush si [install_profile] --account-name=[admin_login] --account-pass=[admin_pass] --db-su=[root_login] \
--db-su-pw=[root_pass] --db-url=mysql://[mysql_user]:'[mysql_pass]'@'localhost'/[mysql_db] --site-name='[sitename]'
[admin_login], [admin_pass] - login and password of the future site administrator (user with id = 1).
[root_login], [root_pass] - login and password from the root user to work with the MySQL database.
[mysql_user], [mysql_pass], [mysql_db] - data for writing settings in settings.php for working with MySQL database.
[install_profile] - Drupal installation profile (choose between “standrad” or “minimal”).
[sitename] - the name of the future site (in the future, you can always change the settings).
The result is something like:
drush si minimal --account-name=admin --account-pass=123456 --db-su=root \
--db-su-pw=654321 --db-url=mysql://username:'password'@'localhost'/database --site-name='My new site on Drupal 7'
3) Now we have a “bare” installed Drupal with a minimum set of modules and in English. Next, we install the modules we need using the
dl (download) command. I will give my own assembly of the necessary modules, it may differ for you:
drush dl drush_language, admin_menu, devel, fancybox, token, ctools, filefield_paths, filefield_sources, jquery_update, l10n_update, module_filter, pathauto, views, ckeditor, insert, transliteration -y
Pay attention to the
l10n_update and
drush_language modules - their installation is required for further work with language settings via Drush (see clause 4). The
drush_language module
must be installed once on the same machine. After successful installation of all modules, we will enable the modules we need using the
en (enable) command:
drush en admin_menu,devel,fancybox,token,ctools,filefield_paths,filefield_sources,jquery_update,l10n_update,module_filter,pathauto,views,ckeditor,contact,field_ui,file,list,menu,number,syslog,admin_menu_toolbar,views_ui,insert,transliteration -y
Everything, now our system has acquired the necessary modules. However, the site will be in English. Unfortunately, a lot of people in our country have not yet acquired enough knowledge of English, so I’ll show you how to quickly translate the entire engine and all modules into Russian.
4) To automatically update the language files of the engine and module, we will use the
indispensable module
l10n_update . And to add a new language through Drush, use
drush_language .
Add and enable Russian by default:
drush language-add ru
drush language-default ru
After that, we just need to update all the translations:
drush l10n-update
That's all. The whole installation process takes 5 minutes and does not require a single mouse click.
PS If this article will be useful to someone, I can consider creating my own installation profile for Drupal in the next article.