In this posts, we list steps to install Drupal site utilizing Drush
Tested: Drush 5.8, Mac 10.7.5, MySQL 5.0.10
Step-1. Download and Install
To download Drupal, run the following in command line:
drush pm-download drupal
This creates folder drupal-x.ver and downdloads drupal. if need specific version, then replace ‘drupal’ to ‘drupal-7.18’ for example
drush pm-download drupal-7.18
2) Rename default folder
After downloading drupal, the drupal code is in default folder – drupal-x.ver. Perhaps, you like to move into name of your website.
sudo mv drupal-7.18 nameOfMySite
3)Create and Set up Database(DB)
Here is how to setup database from the command line interface:
mysql -u USER -p mysql>create database NAME_OF_NEW_DB; mysql>GRANT ALL PRIVILEGES ON NAME_OF_NEW_DB.* TO db_user@'localhost' IDENTIFIED BY 'db_passwd'; mysql>flush privileges;
In line one, we login the mysql server run locally. In line two, the new database is created with name ‘NAME_OF_NEW_DB’. In line three, a new user is crated for the new database and all privileges are granted for that user. In last line, the cache is flushed for our changes to take an effect.
4) Install Drupal
Install Drupal as follows:
cd nameOfMySite sudo drush si --db-url=mysql://dbUser:dbPass@localhost:3306/nameOfDb --account-pass=adminPassword
Here the dbUser, dbPass and nameOfDb are the credentials created in step 3
Besides installing Drupal, it also configures database. The ‘–acount-pass=adminPassword’ specifies password for admin user for the Drupal website.
5. Configure Local DNS
To rout the request to your local drupal instance, update the hosts file. For Unix based systems, it is located at /etc/hosts. If your local domain name is going to be test.com, then insert the following line in the /etc/hosts file:
6. Configure Virtual Host
At last, configure the virtual host for your new site in Apache web server. Depending where is your Apache Web server installed and what version, the location for virtual host settings my differ. In our case, it is located at apacheRoot/conf/extra/httpd-vhosts.conf. So, to configure the virtual host for our new drupal instance, we would insert the following:
... <VirtualHost *:80> DocumentRoot "/path/to/drupal_root_dir" ServerName test.com <Directory /path/to/drupal_root_dir> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost> ...
In line 3 and 5, the directory of our new drupal site is installed. In line 4, the local domain that we configured in previous step is specified.
Afterwards, Restart Apache server to reload virtual hosts configurations
service apache2 restart
sudo /root/To/Apache/dir/bin/apachectl restart
This will restart Apache and load the new configurations
!Some Apache Web Server versions need specifically enable the virtual host, then
sudo a2ensite yoursite
7. Test it!
Open browser and point it to the test.com. If it doesn’t work, see the Troubleshooting section below for help.
Step-2 Set up Root directory
If your web server is configured to service the drupal site from the subfolder than:
a)Specify directory from where the drupal site is serviced from.
In the .htaccess(in site root folder) uncomment line “ReriteBase/drupal” and updated it to the location of your site:
b)Configure the Drupal base Url
To configure Drupal base, uncommenting $base_url in settings.php file( usually in sites/default/settings.php) as follows:
$base_url = 'http://www.example.com/pathToSite';
For making it possible to insert images into text area using WYSIWYG, there are two modules if using WYSIWYG module for your editor solution:
If you are using CKEditor Module for editor solution instead, then the IMCE module is sufficient
The CKEditor works with the above modules. There is currently issue with WYSIGWYG default module to work with CKEditor, but solution is to use the dev(7.x-2.x-dev) module of WYSIGWYG
Step-3 Install other Useful modules
a) JQuery Update – updated jquery module for drupal core (http://drupal.org/project/jquery_update)
drush dl jquery_update-7.x-2.x-dev -y drush en jquery_update-7.x-2.x-dev -y
Note:As you see, we chose the dev version of jquery_update to ensure it contains lates jquery lib version, however, in your case it may be different. Afterwards, select jquery version you wish your drupal site uses by going into admin->modules->jquery_update->Configure and select version
b) Twitter Bootstrap – see post ‘Installing Twitter Bootstrap with Drupal‘
c) WYSIWYG [wysiwyg] – install necessary module before downloading and configuring one of the wysiwyg editors. To install:
drush dl wysiwyg sudo drush en wysiwyg
Once module wysiwyg installed, then enabled it in Admin->Modules->Check ‘wysiwyg’ module and save. Next, press ‘configure’ to see all the available wysiwyg editors with instructions how to install and enable any from the list. Our favorite – WYMEditor
d) Admin Menu [admin_menu]- makes the admin menue items to drop down in hierarchal manner instead one level
drush dl admin_menu sudo drush en admin_menu
e) Path Auto [pathauto] – provides an option to alias url to whatever you choose or auto generate alias url from title field.
drush dl pathauto sudo drush en pathauto
Note: the module ‘pathauto’ dependes on module ‘token’. If installed via drush, then the dependency is installed automatically
f) Date [date] – adds field type of Date with nice date picker UI. To install:
drush dl date sudo drush en date
Afterwards, enable the time pop-up picker in the Admin->Modules section
g) Views[views] – enable to create views that is an excellent feature to aggregate content in custom way for front page or any section of the page for that matter. To install:
drush dl views sudo drush en views
Note: You may be interested in better_exposed_filters module for exposing more enhanced filters to user
Note: the module ‘views’ has dependency of module ‘ctools’ that is auto installed with drush
h)Database Migration – for backing up and migrating database, the backup_migrate is good choice
i)Botcha – to stop spam at form submission including user registertion
Step-4 Developers Modules
a)Theme Developer[devel_themer] – helps to see templates used any page, profiling db queries, generate content and other cool stuff. To install:
drush dl devel_themer drush en devel_themer
!If you install not via drush then make sure your install also the dependencies. With Drush, it does automatically
Few tools from Theme Developer:
- Go to Structure->Blocks and enable Develpers block. In the Developers blog you can select ‘devel setting’ to enable profiling DB queries
- Go to Configuration->Development->Generate Content. This generates some content to work with
- Select ‘Themer info’ right bottom corner to see what templates called, events triggered and variable renedered
b) Block Class IU[block_class] – it enables to add css styling to any block from UI never need to go into code
drush dl block_class drush en block_class
c) Install firebug for Drupal. In Firefox select Tools->Add On->Search with keyword ‘firebug’ and select Drupal Firebug add on. Afterward, restart firefox.
That installs for the browser, but then for firebug support in your drupal development site:
drush dl drupalforfirebug drush en drupalforfirebug
d) Advanced Help [advanced_help] – To access advanced help index (good for developing views). To install
drush dl advanced_help drush en advanced_help
e)Examples For Developers – examples for custom module development
drush dl examples drush en examples
f) Coffee[coffee] – is great UI feature to get around quickly. By pressing AlT+D, it opens the input box where you can type the module or admin functionality you want to get/edit or configure. Afterwards, click the link to go there
g)Module Filter [module_filter] – for assistance on navigating around the modules, the module_filter module is great by filtering and adding extra menu in modules section.
h) Module Instructions[module_instructions] – pulls up all ReadMe files easy available to read in the Modules section
Transform for Versioning and Exporting
Drupal has a way to convert all site or parts of the sites functionality into features for ability to version it into code as well as easy migrating. Here are all the modules that will do the work for Drupal 7:
a)Features – makes it easy for you to export features that is content types, views, etc all of which can be called configurations and content Structure. It packages into a custom module that you can transfer on another Drupal instance
b) uuid features – is integration for Features module that adds a capability for exporting content itself not only the content structure. It also supports file exports, services. Make sure you specify which content structures enabled for the feature module at ‘admin/config/content/uuid_features’. Make sure also create missing UUIDs at admin/config/system/uuid
c)StrongArm – It provides ability to feature variables and configurations
d)commerce_features – it provides ability to feature commerce customer profiles, products, tax rates and types.
d)features_extra – One of the features_extra submodules is fe_blocks. This provides an ability to convert block configurations. This especially useful if your site is using context for organizing blocks and you need disable all the blocks in the ‘structure/blocks’
Besides ‘autopath’ module for url naming, here are other useful SEO related modules
[xmlsitemap] – generates xml site map that is submitted to search engines
b) Site Verify
[site_verify] – provides an easy way to verify your site with search engines
c) SEO Checklist
[seo_checklist] – provides a check list for SEO of your site
c) Google Analytics
[google_analytics] – enables google analytics in site
a) Add This
[addthis] – enables your site users to vote and plus(+1) your products
b) Add To Any
[addtoany] – helps readers share, bookmark, and email your pages and articles (aka stories) using any service, such as Facebook, Twitter, Google+, Pinterest, and other.
c)Enable Menu Title in HTML
Twitter Bootstrap and other CSS styling frameworks often use icons class to insert icons in front of title. By default, Drupal doesn’t permit the title contain html. There is a moduel menu_html that allows easy enable title be html
Entity Reference helps to reference other elements. Really good for building some complex data structures vi UI like photo gallery,podcast,etc.
Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information):gd
Looks like missing php5-gd2.so lib. Run:
sudo port install php5-gd2 sudo port activate php5-gd2
Command site-install needs a higher bootstrap level to run - you will[error] need to invoke drush from a more functional Drupal environment to run this command.
Make sure you are in the directory of drupal that was downloaded in step 1.
...SQLSTATE[HY000]  Access denied for user 'someuser'@'localhost...
Apparently, the mysql user provided to drush unable connect database. Ensure the user is remote localhost enabled. Here is how to test:
mysql -u someuser -p -h localhost
If not then, you have to enable it as remote user as follows:
mysql>GRANT ALL PRIVILEGES ON *.* TO someuser@'localhost' IDENTIFIED BY 'db_passwd'; mysql>FLUSH PRIVILEGES;
This will make user ‘someuser’ as remote access user from ip of ‘localhost
If you able to load from root but unable to go any other pages of the drupal website then it likely an issue with rewrite. To troubleshoot, first check that appache is loading mod_rewrite:
apachectl -t -D DUMP_MODULES
This displays all modules loaded by apache web service. Look to see if ‘rewrite_module’ is present. If it is, then ‘rewrite’ loads, but, apparently, it hasn’t been configured correctly. One way is to have virtual host configuring your drupal portal including rewrite as well:
... <VirtualHost *:80> DocumentRoot "/Users/user/Sites/drupal_root" ServerName drupal-test.com <Directory /Users/user/Sites/drupal_root> Options FollowSymLinks AllowOverride All </Directory> ErrorLog "/private/var/log/apache2/drupal-test.com-error_log" CustomLog "/private/var/log/apache2/drupal-test.com-access_log" common </VirtualHost> ...
The highlighted lines configure the overwrite. The DocumentRoot is folder where your drupal site is serviced from. The ServerName is your configured local DNS name in /etc/hosts file. Put this in your /etc/apache2/extra/httpd-vhosts.conf and uncomment the following line in http.conf:
... Include /private/etc/apache2/extra/httpd-vhosts.conf
This will make apache load this virtual host configuration.
After login as admin, there is following error:
file_put_contents(temporary://devel_themer/: failed to open stream: DrupalTemporaryStreamWrapper::stream_open" call failed in devel_themer_store_krumo()
Apparently, Drupal(devel_themer module) uses local file system for storing temporary files. Make sure the temp folder for drupal got permissions to write. Go to Administration >> Configuration >> Media >> File system and look ‘Temporary Directory’ to find out where is the folder located. Afterwards, enable write permission
5. PDOException: SQLSTATE[HY000]  Connection refused in lock_may_be_available() [..] includes/lock.inc drupal
This error is because Drupal unable to connect to MySQL database. You can double check your DB configurations in settings.php by connecting manually from command line as follows:
mysql -u userName -p -h hostName
Where the userName and hostName is the value from the db configuration in settings.php. Most likely, you don’t have a user with that hostname in the database. To check, run:
SELECT user FROM mysql.user;
And look for the username as well as the hostName. If it doesn’t exist then to create one:
GRANT ALL PRIVILEGES ON db_name.* TO db_user@'hostname' IDENTIFIED BY 'db_passwd';