Skip to content

Instantly share code, notes, and snippets.

@aguestuser
Created May 12, 2015 21:53
Show Gist options
  • Save aguestuser/e834da8e99a223e5dfb2 to your computer and use it in GitHub Desktop.
Save aguestuser/e834da8e99a223e5dfb2 to your computer and use it in GitHub Desktop.
LS INSTALL NOTES

Installing LS

Download MySQL dump

  • not secure to hand this out

  • tables to be removed:

    • api_request
    • api_user
    • address (and dependencies)
    • chat_user
    • delayed_jobs
    • email
    • group_users
    • modification
    • modification_field
    • note (and dependencies)
    • phone
    • scheduled_email
    • sessions
    • sf_guard_user (and dependencies)
    • users -> drop rows, some need seed data -> needs to at least be admin user account
  • questions:

    • where are dependencies that need to be broken?
    • what is the minimum barrier to getting all this data
      • and how can we keep track of who has it?

PHP Install

Dependencies

External Applications/Frameworks

Package Managers

  • Pear
    • package manager for PHP libraries written in PHP
  • Pecl
    • package manager for libraries written in C

Memcached

  • caching framework
  • install with brew

MySQL

  • database

  • install with brew (before installing Sphinx!)

  • instructions for use:

To have launchd start mysql at login: ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents Then to load mysql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist Or, if you don't want/need launchctl, you can just run: mysql.server start

Sphinx

  • search framework
  • install with brew (or your preferred package manager)
  • BE SURE TO INSTALL W/ MYSQL FLAG brew install sphinx --mysql --pgsql
  • need to have previously installed MySQL

Imagemagick

  • library for bitmap image manipulation
  • install via brew

Symphony

  • web framework
  • LS runs version 1.1.9
  • install via pear
  • in sum:
pear channel-discover pear.symfony-project.com
pear remote-list -c symfony
pear install symfony/symfony-1.1.9

PHP Extensions

  • run php -i to get info on your php settings

  • grep for cURL, GD, PDO and Memcache

  • for each option, look for <name of feature> => enabled

  • if missing any extensions, use Pear or Pecl to install them

  • if missing memcache (likely)

    • need to install memcache locally, then install php package
    • here is a good guide
    • in sum:
$ brew install wget autoconf pkg-config libmemcached
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
$ cd /tmp
$ mkdir memcached-work
$ cd memcached-work
$ pecl download memcached
$ open memcached-{{version}}.tgz
$ cd memcached-{{version}}/memcached-{{version}}
$ phpize
$ ./configure
$ make
$ sudo make install
  • add extension = memcached.so to your php.ini file
  • then (to verify it worked and restart apache):
$ php --info | grep memcached\\.
$ sudo apachectl restart

Clone Repo

For a remote server In the web root, create directory and clone the repo

mkdir /var/www/littlesis
cd /var/www/littlesis
git clone git://github.com/littlesis-org/littlesis.git .

For a local install In any directory to which you can point apache:

git clone git://github.com/littlesis-org/littlesis.git .

Database Setup

Create Tables

Some basic MySQL commands (necessary to perfrom below steps)

  • To start MySQL server manually: mysql.server start

  • To have launchd start mysql at login: ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

  • to load mysql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

  • To connect: mysql -uroot

  • Create tables with:

CREATE DATABASE littlesis DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON littlesis.* TO 'littlesis'@'localhost' IDENTIFIED BY 'fakepassword';
CREATE DATABASE littlesis_raw DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON littlesis_raw.* TO 'littlesis'@'localhost' IDENTIFIED BY 'fakepassword';

Configure Permissions

From the littlesis project root, Edit config/databases.yml.dist, enter the connection parameters for the two databases you created, and save as config/databases.yml:

all:
  raw:
    class:      sfDoctrineDatabase
    param:
      dsn:      mysql://littlesis:fakepassword@localhost/littlesis_raw

  main:
    class:      sfDoctrineDatabase
    param:
      dsn:      mysql://littlesis:fakepassword@localhost/littlesis

Import data

  • run:
mysql -u littlesis -p littlesis < fake/path/to/data/dump.sql
  • to verify it worked:

    • enter mysql shell:
    mysql -u littlesis - p littlesis
    
    • ask for tables:
    show tables;

App Configuration

Edit the following files, then save copies without the .dist suffix in the filename

  • config/ProjectConfiguration.class.php.dist

    • add path to symfony install
    • it's NOT what you get from which symfony
    • in my case it was /Users/aguestuser/pear/share/pear/symfony
  • config/sphinx.conf.dist

    • replace bracketed filepaths with actual ones
    • [username], [database], [password], [path/to/mysqld.sock], [path/to/littlesis], [path/to/littlesis/logs]
  • web/.htaccess.dist

    • add relative path to root
  • apps/api/config/app.yml.dist

    • set enable_s3 and enable_s3_assets to true
    • enter api keys (an outside developer would need their own keys...
      • most important is s3 key for images
      • recaptcha is if you need captcha for account creation
      • documentation key is to enable API calls made in API docs pages
  • apps/api/config/settings.yml.dist

    • enter CRSF secret: can be anything you want, best if randomly generated string
  • apps/frontend/config/app.yml.dist

    • api key same as main
    • amazon key
    • site will work without all other keys
  • apps/frontend/config/settings.yml.dist

    • CRSF secret

Apache Configuration

  • pull from either:

  • replace placeholders with actual values for:

    • project root (lines 5, 9, 27, 78)
    • symfony install (lines 16, 17, 85, 89)
  • take a look at /etc/apache2/httpd.conf, change a bunch of things, incl:

    • uncomment LoadModule rewrite_module libexec/apache2/mod_rewrite.so
  • restart apache

    • apachectl -k restart
  • add local domain name pointer for ls & ls api

  • so that apache will route requests

Domain Name Listings

  • in /etc/hosts/ add:
127.0.0.1       ls.local
127.0.0.1       lsapi.local

Rails Install

Dependencies

Redis

brew install redis, then:

  • To have launchd start redis at login: ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
  • Then to load redis now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
  • Or, if you don't want/need launchctl, you can just run: redis-server /usr/local/etc/redis.conf

QT

  • this is an implementation of webkit from the company QT
  • capybara-webkit (which crawls and does awesome stuff for testing) depends on it
  • install with:
brew install qt

RVM (Ruby Version Manager)

If you already have RVM, skip this. If not, this is a good guide, the highlights of which are these commands:

$ curl -sSL https://get.rvm.io | bash -s stable
$ rvm get stable
$ rvm requirements
$ brew install libtool libxslt libksba openssl libyaml

Ruby/Rails

We are using ruby v 2.1.2 of ruby (w/ rails v 4.1.0). So (assuming you have RVM installed), run:

$ rvm install 2.1.2 --with-openssl-dir=$HOME/.rvm/usr
$ rvm use 2.1.2@ls --create --default
$ which gem
$ gem update
  • last line verifies you're using correct gemfle
  • if missing gem altogether, download RubyGems
  • then install rails:
$ gem install rails --version 4.1.0

Config files

  • database.yml.sample
    • add db password -> test db should NOT be the same as dev!!!
  • lilsis.yml.sample
  • same all-stars (aws keys, api key, etc..)

Run Setup Scripts

  • install and update all gems in gemfile
$ bundle install
$ bundle update
  • format some stuff:

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
line 449

## Sphinx

* keeps a search index in memory (or in file?)
* based off of SQL queries it runs every so often
* keeps a master index and a delta index (things that have changed)
* curious: how does it compare to elastic search

### Configure Sphinx
* edit `<project_root>/config/sphinx.conf.dist` (assuming haven't already)
* create log files for logs specified in `searchd` block of `sphinx.conf`:

```shell
cd <project_root>/log
mkdir searchd
cd searchd
touch searchd.log
touch query.log
touch searchd.pid
chmod a+w *
  • generate indexes:
indexer --config config/sphinx.conf --all
  • start searchd:
searchd --config config/sphinx.conf

Git

Env Variables

Or some other solution to keep keys DRY...

A list:

  • AWS_PUBLIC_KEY
  • AWS_PRIVATE_KEY
  • LS_API_KEY
  • PHP_PROJECT_ROOT
  • RAILS_PROJECT_ROOT
  • SYMFONY_HOME

TO RUN

  • from ~/code/ls/rails:
$ redis-server
$ RAILS_ENV=development bin/delayed_job start
$ RAILS_ENV=development rails server
  • from ~/code/ls/php/:
mysql.server start
memcached
indexer --config config/sphinx.conf --rotate
searchd --config config/sphinx.conf
symfony cc
  • if first time, run before searchd:
indexer --config config/sphinx.conf --all

More Config stuff

  • add these to my apache route:
ProxyPass /topics http://127.0.0.1:3000/topics
ProxyPass /mini-profiler-resources http://127.0.0.1:3000/mini-profiler-resources

Inspect Apache logs

cat /var/log/apache2/accesslog -n <num_lines>

OR:

ls.dev/frontend_dev.php if that works but prod doesn't, try

ls.dev/frontend_staging.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment