Skip to content

Instantly share code, notes, and snippets.

@neisdev
Created July 31, 2023 07:15
Show Gist options
  • Save neisdev/f56573064ad7496b418d005b9cd7079f to your computer and use it in GitHub Desktop.
Save neisdev/f56573064ad7496b418d005b9cd7079f to your computer and use it in GitHub Desktop.
Drupal Recipe

Drupal Recipe

This is a recipe for a fast Drupal installation. Customization level: Custom Site name, custom site password, custom database password, configured drush alias

A Pen by Franco Cedillo on CodePen.

License.

<div ng-app='DrupalRecipe'>
<table>
<tr>
<td>
<label>Name:</label>
<input type="text" ng-model="Name" placeholder="Enter a name here" />
</td>
</tr>
<tr>
<td>
<label>Web App Path:</label>
<input type="text" ng-model="WebAppPath" placeholder="Web App Path" />
</td>
</tr>
<tr>
<td>
<label>E-mail:</label>
<input type="text" ng-model="E_mail" placeholder="Enter a e-mail here" />
</td>
</tr>
<tr>
<td>
<label>Site Admin Pass:</label>
<input type="text" ng-model="WEB_PASS" placeholder="Web admin Password" />
</td>
</tr>
<tr>
<td>
<label>DB Password:</label>
<input type="text" ng-model="DB_PASS" placeholder="DB Password here" />
</td>
</tr>
<tr>
<td>
<label>Database Superuser:</label>
<input type="text" ng-model="DB_SU" placeholder="DB Super User name" />
</td>
</tr>
<tr>
<td>
<label>Database Superuser Password:</label>
<input type="text" ng-model="DB_SU_PW" placeholder="DB Super User pwd" />
</td>
</tr>
<tr>
<td>
<form>
<input type="radio" ng-model="os" ng-value="{name: 'osx', editor:'open -a TextMate', vhost:'/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf', vhostFileDisplay: 'none', errorLogPath: '/Applications/MAMP/logs', webserver: '_www' }" /> OS X
<input type="radio" ng-model="os" ng-value="{name: 'linux', editor:'mousepad', vhost:'/etc/apache2/sites-available', vhostFileDisplay: 'inline', errorLogPath: '${APACHE_LOG_DIR}', webserver: 'www-data' } " /> Linux
</form>
</td>
</tr>
</table>
<hr>
<h1>Project: {{Name}}</h1>
<pre>
replicate drupal in htdocs
cp -r {{WebAppPath}}/drupal-7.26 {{WebAppPath}}/{{Name}}.com
add to hosts
sudo {{os.editor}} /etc/hosts
127.0.0.1 {{Name}}.com www.{{Name}}.com
add to vhosts
<span>sudo {{os.editor}} {{os.vhost}}</span><span style="display: {{os.vhostFileDisplay}}">/{{Name}}.conf</span>
<span style="display: {{os.vhostFileDisplay}}">sudo a2ensite {{Name}}.conf</span>
<span style="display: {{os.vhostFileDisplay}}">sudo service apache2 reload</span>
###########################################################################
&lt;VirtualHost *:80&gt;
ServerName {{Name}}.com
ServerAlias www.{{Name}}.com
DocumentRoot "{{WebAppPath}}/{{Name}}"
ServerAdmin {{E_mail}}'
&lt;Directory {{WebAppPath}}/{{Name}}&gt;
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
&lt;/Directory&gt;
ErrorLog "{{os.errorLogPath}}/{{Name}}.com-error.log"
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel notice
CustomLog "{{os.errorLogPath}}/{{Name}}.com-access.log" common
&lt;/VirtualHost&gt;
###########################################################################
{{Name}}db
{{Name}}dbuser
{{DB_PASS}}
add to drushrc.php
{{os.editor}} ~/.drush/local.aliases.drushrc.php
########################################################################
&lt;?php
$aliases['{{Name}}'] = array(
'root' => '{{WebAppPath}}/{{Name}}',
'uri' => '{{Name}}.com',
'db-url' => 'mysql://{{Name}}dbuser:{{DB_PASS}}@localhost/{{Name}}db',
'databases' => array (
'default' => array (
'default' => array (
'driver' => 'mysql',
'username' => '{{Name}}dbuser',
'password' => '{{DB_PASS}}',
'port' => '',
'host' => 'localhost',
'database' => '{{Name}}db',
),
),
),
'command-specific' => array (
'site-install' => array (
'site-name' => '{{ Name | capitalize }}',
'site-mail' => '{{E_mail}}',
'account-name' => '{{Name}}admin',
'account-mail' => '{{E_mail}}',
'account-pass' => '{{WEB_PASS}}',
'db-url' => 'mysql://{{Name}}dbuser:{{DB_PASS}}@localhost/{{Name}}db',
'db-su' => '{{DB_SU}}',
'db-su-pw' => '{{DB_SU_PW}}',
),
),
);
########################################################################
drush @{{Name}} si
firefox {{Name}}.com
drush @{{Name}} dl ctools views token pathauto features diff
drush @{{Name}} en ctools views token pathauto views_ui features diff
CREATE DATABASE {{Name}}db DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
GRANT ALL PRIVILEGES ON {{Name}}db.* TO {{Name}}dbuser@localhost IDENTIFIED BY "{{DB_PASS}}";
FLUSH PRIVILEGES;
EXIT
sudo chown -R {{os.webserver}} {{WebAppPath}}/{{Name}}
sudo chgrp -R webdev {{WebAppPath}}/{{Name}}
sudo chmod -R u+rw {{WebAppPath}}/{{Name}}
sudo chmod -R g+rw {{WebAppPath}}/{{Name}}
</pre>
</div>
var app = angular.module('DrupalRecipe',[]);
app.filter('capitalize', function () {
"use strict";
return function (input) {
if (input === undefined)
input = '';
return input.charAt(0).toUpperCase() + input.slice(1);
};
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.5/angular.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment