-
You should have drush and git setup on your computer as well as some server software to host your site (MAMP, LAMP, WAMP)
-
You should have access to some sort of command line/shell so you can type in the commands necessary to get this up and running
Step 1: You will be navigating to your basic http directory and installing the drupal core files. Once in your http/www directory, you can do this by executing the following drush command:
drush dl drupal
This will install the drupal core files into a folder called drupal-7.xx. If you want to rename this folder you can run the command:
mv drupal-7.xx mydrupal
Step 2: Next up we will want to add the profile for our site. This will involve cloning the repository containing our files into the appropriate place. Navigate to the profiles directory and clone the git repository:
../mydrupal/profiles>git clone url_to_repository
This will create a folder with the machine name of your install profile in your profiles folder. This will be the root directory where most of your work on the website will go.
Step 3: The next step will be to create the mysql database for the site if you haven't already. You can do this using phpmyadmin or you can use the following commands.
mysqladmin -u USER -pPASSWORD create DBNAME;
There could be some issues if you haven't create a user for yourself in mysql with the appropriate privileges. If that is the case, you can create a new user with mysql superpowers using the following command. (you will need to be logged into mysql using the root user)
CREATE USER 'user'@'localhost' IDENTIFIED by 'password'; GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
you probably won't need to do that though.
Step 4: At this point you should have the repository cloned and the files in your /profiles/projectname/ directory, you should have a mysql database setup and you should have the drupal core files installed. You should now run the rebuild.sh script which will install the modules specified in the install profile.
../mydrupal/profiles/projectname>./rebuild.sh
There could be a few issues when running this. One is if you do not have execute permissions on rebuild.sh. You can fix this with the command
chmod u+x rebuild.sh
Another problem could be if somehow you don't have access to write in your drush cache directories. you would locate your .drush directory (often times it will be a hidden directory in your home directory and either change the owner or set the permissions to be able to write in those cache directories
Step 5: To install drupal, you will need a few folders and files to be writeable by the server, you would go to the mydrupal/sites/default folder and run the following commands:
cp default.settings.php settings.php mkdir files chmod g+w settings.php chmod g+w files chmod g+w ../default
These set the permissions for these files and directory to be writeable by the group associated with the file. You can check who the user/group is for a file by running the command :
marc@ordeau:/var/www/vhosts/da$ ls -al total 260 drwxrwxr-x 9 marc www-data 4096 Feb 13 14:30 . drwxrwxr-x 11 marc www-data 4096 Feb 9 11:46 .. -rw-rw-r-- 1 marc www-data 6553 Feb 9 11:45 authorize.php -rw-rw-r-- 1 marc www-data 74911 Feb 9 11:45 CHANGELOG.txt -rw-rw-r-- 1 marc www-data 1481 Feb 9 11:45 COPYRIGHT.txt -rw-rw-r-- 1 marc www-data 720 Feb 9 11:45 cron.php ...
Here we can see that the user for these files is "marc" and the group owner is "www-data". Apache is part of this group so we are giving apache permission to write to those files.
You are now ready to install your profile. You should doublecheck you've done the following things:
- downloaded drupal core
- cloned the git repo for your profile into /profiles
- created a database for your site
- created a settings.php file, a files directory and changed permissions on the necessary files and folders to be able to run the install.
- run the rebuild.sh script and confirmed that it downloaded the modules it was supposed to.
Step 6: You navigate to the url of your drupal install and run install.php. One of the options should be your install profile. select that one and give drupal all the info it wants during the process.
When committing changes to the repository, you will first give yourself a local branch specific to the task you are working on. If you are using an issue tracker, it is customary to include the issue id in the name of the branch so that people can find the issue that relates to your branch. Suppose we wanted to edit this README.md file and append some additional instructions to it. We begin by creating a branch to work on:
/profiles/projectname>git checkout -b 01-adding-blah-to-readme Switched to a new branch '01-adding-blah-to-readme'
You will now edit the README.md file and save your changes. You can run
git status
to see that git has noticed that you changed that file. You should now add the file so that the changes will be added when you commit them.
git add README.md
You can now commit the changes and you should add a message indicating what you did
git commit -m"Added extra git workflow steps to the README.md"
You now need to push the changes back to the remote repository. If your branch does not exist there, simply doing git push may not work. You should run the command:
git push -u origin 01-adding-blah-to-readme
Your remote repository should now have your branch and whomever is in charge of merging should take over from there.
To merge the changes, you would first inspect the difference between the current branch and the new branch.
git fetch origin git checkout master git diff 01-adding-blah-to-readme
Once you are satisfied everything is alright
git merge 01-adding-blah-to-readme git push
Features allows us to take information that would normally be stored in the database and move it into code. This is very useful especially for things like version control. As an example of how to use features, we will create a content type and then export it to a module and add it to our repository.
Navigate to your new drupal site. Provided you are logged in, you will have a menu at the top. Go to Structure>Content Types and Add a new content Type. Configure your content type and add any fields that are required. We will assume the content is an Event and the feature will have the machine name event_feature.
Once that is done, go to Structure>Features and add a new Feature. You will be able to select the new Event content type you just created. You can then download the event_feature tar ball. this will include a module that will tell drupal to add your content type when it is enabled on a site.
Create a new branch on your local git repository called "02-added-event-feature". make sure that branch is checked out and then untar the features file you downloaded and copy it to your module directory in /profiles/projectname/modules/features/. you should now have a directory called /profiles/projectname/modules/features/event_feature/ which contains the module files for your event content type.
Doing a git status will show a new feature directory. Run the git add command to add your directory
git add modules/features
or
git add modules/features/event_features
Navigate to the projectname.install and inside you will see a list of modules to be enabled when the profile is installed. You can add your feature there under the //Features section 'event_feature',
The insides of the .install file will look like this:
... // Enable modules $module_enable(array( //Contrib 'update', ... //Custom modules. custom_config, //Features. ...
You should add it so that the file looks like:
... // Enable modules $module_enable(array( //Contrib 'update', ... //Custom modules. custom_config, //Features. 'event_feature', ...
Save your changes. If you now do a git status you will see that you've modified the .install file. Do a "git add" command to add this file and now commit all your changes
git commit -m"added event-feature to the profile which creates an event content type" git push -u origin 02-added-event-feature
Your new feature should now be in a branch on the remote repository, ready to be merged.