GOAT logo

Join the conversation! The forum activity is now at GOATeach.org!  We are working to cross pollinate our conversations. Document and share tools at farm hack and talk at GOAT!  Also join GOAT riot and introduce yourself and your projects!

Farm Hack Web Committee documents organized

Topic Type: 
Information

I organized some documents on the Farm Hack Hack Pad site into a "Farm Hack Web Committee" Collection. Check it out here.

jbd's picture

Note the requirements!

Spent Monday evening with RJ trying to create a sandbox FarmHack.net site. Got it working!

Assumptions are:

  • You're using Ubuntu 12.04.5 LTS (Note: This is NOT MS-Windows or Apple MacIntosh) with a LAMP stack. (LAMP = Linux, Apache, MySQL, and PHP).
  • You're using the Apache 2 web server (this comes with Ubuntu)
  • You have sudo access (permissions to execute privileged commands)
  • You understand git ('git' is a program name, and not a typo).
  • You understand ssh and PKI (and how keys work)
  • You have 'drush' on your system.
  • You have copied the Live site (all the Drupal files), the database, and the non-Drupal files to a location on your local computer.

If you don't understand any of the above assumptions, then you should get a mentor to help. RJ Steinert, Mike Stenta, or Bruce Dawson have experience as of this writing.

The procedure (for Ubuntu) is as follows:

  1. Create a directory to put the site in. I'm using ~/Desktop/FarmHack/devweb. Note that the Apache2 log files will go in ~/Desktop/FarmHack.
  2. cd to ~/Desktop/FarmHack/devweb. Then "mkdir .git" (make a directory for git).
  3. Create a Git configuration file (~/Desktop/FarmHack/devweb/.git/config) with the following content: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "getpantheon"] url = ssh://codeserver.dev.adabf944-5abf-457b-a44c-bc74efaabcf3@codeserver.dev.adabf944-5abf-457b-a44c-bc74efaabcf3.drush.in:2222/~/repository.git fetch = +refs/heads/*:refs/remotes/getpantheon/*
  4. cd to ~/Desktop/FarmHack/devweb and use the command "git pull getpantheon"
  5. You will then need to execute 'git reset --hard' to eliminate the metadata created by the 'git pull'.
  6. Next, from the same directory, you'll have to perform a 'git merge getpantheon/master'.
  7. The next steps involve getting the Apache2 webserver and the MySQL database configured.
  8. cd to /etc/apache2/sites-available
  9. Create a file named 'farmhack.sandbox' with the following content: <VirtualHost *:80>      ServerAdmin webmaster@localhost      ServerName FarmHack.sandbox      RewriteEngine On     RewriteOptions inherit      DocumentRoot /home/jbd/Desktop/FarmHack/devweb      # Possible values include: debug, info, notice, warn, error, crit,      # alert, emerg.      LogLevel warn      CustomLog /home/jbd/Desktop/FarmHack/access_log combined      ErrorLog /home/jbd/Desktop/FarmHack/error.log      <Directory /home/jbd/Desktop/FarmHack/devweb>          Options FollowSymLinks          AllowOverride All      </Directory> </VirtualHost>
  10. Enable the site by going to the Apache sites-enabled directory and creating a symlink to the farmhack.sandbox file created previously:cd ../sites-enabled/sudo ln -s ../sites-available/farmhack.sandbox .
  11. Next, tell Apache to reload its configuration files:sudo /etc/init.d/apache2 reload
  12. Make farmhack.sandbox a host by adding it to your /etc/hosts file:sudo vi /etc/hostsAt then end of the file, add the line:127.0.0.1 farmhack.sandboxand exit the editor.

  13. Create the database by loading what you copied from the getpantheon live backup site, specificially the database file. First you'll have to unzip it:gunzip farmhack_live_2014-12-23T00-07-18_UTC_database.sql.gzThis will create a farmhack_live_2014-12-23T00-07-18_UTC_database.sql file - and remove the ...gz file. You'll note the .sql file is larger than the .gz file - the gunzip command simply uncompresses the file. The next step will be to create the database.mysqladmin -u debian-sys-maint -p create rjstatic_farmhack_beta1The above mysqladmin command will create the database (but not populate it). However, you have to give the command a privileged user and password (-u debian-sys-maint, and -p). The user and password is found in /etc/mysql/debian.cnf (you'll need to use sudo to view the file). The next thing you have to do is permit the user and password in the settings.php file to have access to the database. This is done by using the mysql command to grant permissions to that user:mysql -u debian-sys-maint -p mysqlcreate user 'rjstatic_beta1'@'localhost' identified by 'XXX';grant all on rjstatic_farmhack_beta1.* to 'rjstatic_beta1'@'localhost';flush privileges;

    In the above, replace 'XXX' with the password that you got from the settings.php file

  14. Now, load the data into the database with the following command:mysql -u rjstatic_beta1 -p rjstatic_farmhack_beta1 <farmhack_live_2014-12-23T00-07-18_UTC_database.sql

  15. Next, change the $base_url variable in the settings.php file to:$base_url = 'http://farmhack.sandbox';  // NO trailing slash! 

  16. The settings.php file is in the sites/default directory of the website. In my instance, this was ~/Desktop/FarmHack/devweb/sites/default/setings.php

  17. The next step is to reset the caches:sudo drush vset preprocess_js 0 --yessudo drush vset preprocess_css 0 --yessudo drush vset cache 0 --yes

  18. Now, you have to create a temporary directory:cd ~/Desktop/FarmHack/devwebmkdir tmpchmod 777 tmp

  19. The last step is to login to the web site as the first user - also known as the admin user.drush uli

  20. Finally, you should go to http://farmhack.sandbox, and you should be logged in as user1.

You can now work on the site without disturbing the production site at http://farmhack.net