Skip to content

Instantly share code, notes, and snippets.

@helmut-hoffer-von-ankershoffen
Last active October 7, 2016 05:54
Show Gist options
  • Save helmut-hoffer-von-ankershoffen/8664153 to your computer and use it in GitHub Desktop.
Save helmut-hoffer-von-ankershoffen/8664153 to your computer and use it in GitHub Desktop.
Setup Development Mac
# How to set up a basic 20steps {Pages,Shop,Workflow,Control,Cloud} development stack on a Mac
#
# Includes setup of Apache, PHP, MySQL, MongoDB, git, Symfony2, Wordpress, 20steps Pages etc.
# Includes auto-deployment one-liner ,-)
#
# Author: Helmut Hoffer von Ankershoffen (helmuthva@20steps.de)
# Version: 1.0 (29.01.2014)
# preconditions:
# - Mavericks installed (10.9.1 or newer)
# - Ports, Fink or Homebrew not installed
# - current user has Administrator rights
# - installation of non-signed software allowed on Mac (Settings -> Security -> Unlock -> "Keine Einschränkungen"
# - Office management prepared your @20steps.de E-Mail address
# - Your department head created your account at http://git.20steps.de and invited you to the 20steps Pages and "genericConf" project
# recommendation:
# - the whole procedure needs ca. 15 minutes of your attention and ca. one hour to download everything
# - make your first coffee at 20steps, play with your favorite office dog or do some pair programming with your colleague
# while downloading ,-)
# prepend /usr/local/(s)bin in PATH variable
# you might have to adapt this if you already have a .bash_profile
echo "export PATH=~/bin:/usr/local/bin:/usr/local/sbin:$PATH" >> ~/.bash_profile
echo "export COMPOSER_PROCESS_TIMEOUT=1200" >> ~/.bash_profile
source ~/.bash_profile
# unlink mysql, php etc. (might be linked in /usr/local/bin from previous MAMP installation)
rm -f /usr/local/bin/mysql
rm -f /usr/local/bin/mysqldump
# install homebrew (excellent package manager for Mac OS X, cp. http://brew.sh/)
# Will install XCode command line tools
# Will ask for password
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew doctor
# get some more repositories for homebrew recipes
brew tap josegonzalez/homebrew-php
brew tap homebrew/dupes
# install basics using homebrew
brew install git
brew install php54 --with-mysql
brew install php54-apc
brew install php54-intl
brew install php54-mcrypt
brew install mongo
brew install php54-mongo
brew install composer
brew install mysql
brew install wget
brew install node
# now we install bower a 'package manager" for js and css
sudo npm install -g bower
# setup git for current user (replace "full name" and "user@20steps.de" appropriately)
git config --global user.name "full name"
git config --global user.email "user@20steps.de"
#create LaunchAgentsFolder in case it dows not exist
mkdir -p ~/Library/LaunchAgents
# setup autostart of mysql and start now
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# setup autostart of mongodb and start now
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
# manually download and install SQL client, Mongo Client and Sublime editor
http://www.sequelpro.com
https://github.com/fotonauts/MongoHub-Mac
http://www.sublimetext.com/3 // sublime or ..
http://www.jetbrains.com/phpstorm/ // phpstorm if you like emacs more than vi ,-)
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
# get license key for sublime3 from your department head
# check mysql and mongo up and running
# start sequelpro, click on socket, user root, no password -> Verbinden
# startup MongoHub, add connection "local", connect
# setup 20steps Pages database using SequelPro
# get dump from prelive
# import dump via "Ablage -> Importieren -> sql -> ..."
# create 20steps projects directory
sudo su -
cd /
mkdir Projects
# replace your username on next line with your local username
chown username Projects
exit
cd /Projects
mkdir -p twentysteps/Pages
# Create RSA-Keypair (replace user@20steps.de with your E-Mail address)
cd ~
ssh-keygen -t rsa -C "user@20steps.de"
# login at http://git.20steps.de using your e-mail address
# connect to 20steps VPN if you are not on-premises in cuvry- or zimmerstraße
# change password of your git account
# paste your public key (~/.ssh/id_rsa.pub) in your 20steps gitlab account (http://git.20steps.de)
# send your public key to your department head who will allow access to test, prelive and live segments of the 20steps cloud
# clone pages projects from git.20steps.de
cd /Projects/twentysteps/Pages
git clone git@git.20steps.de:twentysteps/pages.git .
# setup pages project (set color and stage, use composer to resolve dependencies and load external packages)
echo "twentysteps" > deploy/color
echo "dev" > deploy/stage
deploy/setup
deploy/git-add-remotes
# clone genericConf - this is where the webserver config is managed
cd /Projects/twentysteps/
mkdir genericConf; cd genericConf
git clone git@git.20steps.de:twentysteps/genericconf.git .
# if github timeouts ...
# call "composer install" repeatedly until all packages are downloaded
# get hosts from genericConf
sudo su -
cd /etc
cp hosts hosts.orig
rm hosts
cp /Projects/twentysteps/genericConf/hosts hosts
exit
# you will have to repeat the sudo cp ... for every update in git (as MacOS X does not allow symlinking /etc/hosts :-/)
# check test site
ping cynosure.localhost.com
# should resolve to 127.0.0.1
sudo emacs -nw /etc/apache2/httpd.conf
# inject php module - possibly correct php version in the following string
# LoadModule php5_module /usr/local/Cellar/php54/5.4.27/libexec/apache2/libphp5.so
# change variable User to your username
# include vhost config (ca. line 480)
Include /Projects/twentysteps/genericConf/httpd-vhosts.conf.dev
# update php.ini
subl /usr/local/etc/php/5.4/php.ini
# increase "memory_limit" to 2G
# set date.timezone to "Europe/Berlin"
# update config of APC bytecode cache
subl /usr/local/etc/php/5.4/conf.d/ext-apc.ini
# increase cache size: "apc.shm_size=2G"
# enable apc for cli: "apc.enable_cli=1"
# restart apache
sudo apachectl restart
cd /Projects/twentysteps/Pages
sudo chmod -R 777 var/cache/
sudo chmod -R 777 var/logs/
sudo rm -rf var/cache/*
# get database and media dump from prelive
# replace "password" with the correct password as given in app/config/parameters....
ssh root@proc1.20steps.de
mysqldump --user=twentysteps --password=password twentysteps_pages_prelive > twentysteps_pages_prelive.sql
cd /var/www/vhosts/20steps.de/prelive.pages.20steps.de/web/wp-content/uploads/sites
tar czvf /var/www/vhosts/20steps.de/sites.tgz *
exit
cd ~
scp root@proc1.20steps.de:twentysteps_pages_prelive.sql twentysteps_pages_prelive.sql
scp twentysteps@proc1.20steps.de:sites.tgz sites.tgz
# import mysql dump
# open sequelpro
# connect to localhost ass root (no password)
# create a new databse named "twentysteps_pages_dev"
# import mysql dump via ablage -> importieren -> .sql -> ...
# copy media dump using ...
cd /Projects/twentysteps/Pages/web/wp-content/uploads/sites
tar xzvf ~/sites.tgz
# adapt a page cp. cynosure.localhost.com
# sequelpro -> open db 20steps.pages.dev
# wp_site: prelive.pages.20steps -> localhost.com
# lookup cynosure in wp_blogs
# cynosure.pages.20steps.de -> cynosure.localhost.com
# same in wp_domain_mapping
# replace $id with the id of the blog as found in wp_blogs
# same in wp_$id_options (update entries siteurl and home)
# navigate to the local site:
# http://cynosure.localhost.com
# or the customer and admin frontend of 20steps pages (login with the credentials given by your department head)
# http://localhost.com/secure/login
# you will find the apache error.log via
less /var/log/apache2/error_log
# start coding ,-)
# open Sublime 3, drop in /Projects/twentysteps/Pages
# deploy to prelive (a git hook at the remote will redeploy and reconfigure the remote setup including auto-updating of any dependencies)
cd /Projects/twentysteps/Pages
# please replace "update" with your specific commit message
git add .; git commit -am "update"; git pull prelive.pages.20steps.de; git pull origin master; git push prelive.pages.20steps.de master; git push origin master
# in case the webserver got stuck due to heavy traffic during deployment ...
ssh root@proc1.20steps.de
killall httpd; service httpd restart; service varnish restart
# in case of emergency ...
cd /var/www/vhosts/20steps.de/prelive.pages.20steps.de/
chmod -R 777 var/cache/*
# in case of great emergency ...
https://askhelmut.com/ ,-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment