Advertisement
kyroskoh

cartodb.sh

Jul 6th, 2015
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. ###################################
  2. ## CartoDB 2.0 Install [Working] ##
  3. ## Tested on Ubuntu 12.04 ##
  4. ###################################
  5.  
  6. # Change password
  7. passwd
  8. adduser [username]
  9. adduser [username] sudo
  10.  
  11. ## LOGIN AS [USERNAME]
  12.  
  13. # Basic upgrades
  14. sudo aptitude update
  15. sudo aptitude safe-upgrade -y
  16.  
  17. # Install miscellaneous dependencies packages
  18. sudo aptitude install -y git-core python-software-properties openmpi-bin libopenmpi-dev build-essential libxslt-dev zlib1g-dev ruby gems unzip
  19.  
  20. # Install RVM
  21. bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
  22.  
  23. ## REBOOT
  24.  
  25. # Install ruby and its dependencies
  26. rvm pkg install openssl
  27. # rvm pkg install zlib
  28. rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr # Not sure this needs to be specified
  29. ## ENTER q
  30. rvm use 1.9.2
  31. rvm use 1.9.2 --default
  32. sudo aptitude install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
  33.  
  34. # Install CartoDB repo and unp
  35. git clone --recursive https://github.com/CartoDB/cartodb20.git
  36. cd cartodb20
  37. git checkout master
  38. git submodule update
  39. git submodule foreach git checkout master
  40. sudo aptitude install -y unp
  41.  
  42. # Install GDAL, GEOS, PROJ, JSON-C, and PostGIS
  43. echo 'yes' | sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
  44. sudo apt-get update
  45. sudo apt-get install -y libgdal-dev libgeos-dev libproj-dev gdal-bin postgis postgresql-plpython-9.1 libjson0 libjson0-dev python-gdal
  46.  
  47. # Install Redis
  48. sudo aptitude install -y redis-server
  49.  
  50. # Install python dependencies
  51. sudo aptitude install -y python-setuptools python-dev
  52. sudo easy_install pip
  53. cd cartodb20
  54. ## ENTER 'y' -- maybe hit 'n'?
  55. sudo pip install -r python_requirements.txt
  56. sudo pip install -e git+https://github.com/RealGeeks/python-varnish.git@0971d6024fbb2614350853a5e0f8736ba3fb1f0d#egg=python-varnish
  57. ## ENTER 's'
  58. cd ~
  59.  
  60. # Install Mapnik
  61. echo 'yes' | sudo add-apt-repository ppa:mapnik/v2.0.2
  62. sudo apt-get update
  63. sudo aptitude install -y libmapnik mapnik-utils python-mapnik libmapnik-dev
  64.  
  65. # Install Node (For CDB 2.0, need version higher than what apt has, v0.6.12, so we will install from source.)
  66. git clone https://github.com/joyent/node.git
  67. cd ./node
  68. git checkout v0.8.25-release ## 0.6.19 version works (I think?) with both CartoDB-SQL-API and Windshaft but try 0.4.12
  69. ./configure
  70. make
  71. sudo make install
  72. cd ..
  73.  
  74. # Install npm
  75. curl https://npmjs.org/install.sh | sudo sh
  76.  
  77. ## Install CartoDB SQL API (need nodejs 0.8.x; works on 0.8.25)
  78. git clone git://github.com/Vizzuality/CartoDB-SQL-API.git
  79. cd CartoDB-SQL-API
  80. sudo npm install
  81. cd ..
  82.  
  83.  
  84. ## Mapnik requires a ton of RAM to compile, so setup a swapdisk if needed.
  85. cd /
  86. sudo dd if=/dev/zero of=swapfile bs=1M count=3000
  87. sudo mkswap swapfile
  88. sudo swapon swapfile
  89. sudo pico /etc/fstab ## Add: /swapfile none swap sw 0 0
  90. cd ~
  91.  
  92. ## To try: install mapnik latest PPA
  93. ## Install nvm and install 0.6.19 from it (For CDB 2.0 install, seems to work fine with node v0.8.25)
  94. git clone git://github.com/Vizzuality/Windshaft-cartodb.git
  95. cd Windshaft-cartodb
  96. sudo npm install
  97. cd ../
  98.  
  99. cd cartodb20
  100. bundle install --binstubs
  101.  
  102. ## Set the right stuff here!
  103. mv config/app_config.yml.sample config/app_config.yml
  104. pico config/app_config.yml
  105.  
  106. mv config/database.yml.sample config/database.yml
  107. pico config/database.yml
  108.  
  109.  
  110. # Install varnish
  111. sudo curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add -
  112. sudo pico /etc/apt/sources.list
  113. # ADD: deb http://repo.varnish-cache.org/ubuntu/ lucid varnish-3.0
  114. sudo aptitude update
  115. sudo aptitude install varnish
  116.  
  117.  
  118. ## This inits the postgres–CartoDB connection & DBs
  119. sed -i 's,some_secret,3b7de655b4a0064e0e08a7dc4a3eb156,g' ~/cartodb20/config/app_config.yml
  120. sudo rm /etc/postgresql/9.1/main/pg_hba.conf
  121. sudo touch /etc/postgresql/9.1/main/pg_hba.conf
  122. sudo sh -c "echo 'local all postgres trust' >> /etc/postgresql/9.1/main/pg_hba.conf "
  123. sudo sh -c "echo 'local all all trust' >> /etc/postgresql/9.1/main/pg_hba.conf "
  124. sudo sh -c "echo 'host all all 127.0.0.1/32 trust' >> /etc/postgresql/9.1/main/pg_hba.conf "
  125. sudo sh -c "echo 'host all all ::1/128 trust' >> /etc/postgresql/9.1/main/pg_hba.conf "
  126. sudo chown postgres:postgres /etc/postgresql/9.1/main/pg_hba.conf
  127. sudo /etc/init.d/postgresql restart
  128.  
  129.  
  130. # Setup PostgreSQL with needed template
  131. sudo pg_dropcluster --stop 9.1 main
  132. sudo pg_createcluster --start -e UTF-8 9.1 main
  133.  
  134.  
  135. sudo su - postgres
  136. cd ~
  137.  
  138. pico template # Add the following:
  139. #####
  140. #!/bin/bash
  141. POSTGIS_SQL_PATH=/usr/share/postgresql/9.1/contrib/postgis-2.0
  142. createdb -E UTF8 template_postgis
  143. createlang -d template_postgis plpgsql
  144. psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis'"
  145. psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
  146. psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
  147. psql -d template_postgis -f $POSTGIS_SQL_PATH/legacy.sql
  148. psql -d template_postgis -f $POSTGIS_SQL_PATH/rtpostgis.sql
  149. psql -d template_postgis -f $POSTGIS_SQL_PATH/topology.sql
  150. psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
  151. psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
  152. #####
  153. chmod +x template
  154. ./template
  155.  
  156.  
  157. export SUBDOMAIN=yoursubdomain
  158. echo "127.0.0.1 ${SUBDOMAIN}.localhost.lan" | sudo tee -a /etc/hosts
  159. sh script/create_dev_user ${SUBDOMAIN}
  160. exit
  161.  
  162.  
  163. # touch ~/cartodb/config/redis.conf # Needed for CDB 2.0?
  164. rails server -p 3000 ## Don't need this if starting with foreman as below
  165.  
  166.  
  167.  
  168. # EXPERIMENTAL
  169. ## make sure to rvmsudo any rails command that needs sudoing
  170. ## Also, be sure to make sure POSTGRES and REDIS aren't launching on boot if using foreman.
  171. ## (Could also change PROCFILE to restart these services rather than just starting them)
  172. ## also make sure postgres default port is 5432 and not 5433.
  173.  
  174. rvmsudo bundle exec foreman start -p 80
  175.  
  176. ## OR add it add a startup item (can control via start cartodb, stop cartodb, restart cartodb)
  177. rvmsudo foreman export upstart /etc/init --start-on-boot --user eric --port 80 --app cartodb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement