SHARE
TWEET
Reddit Open Source - Installation Guide
a guest
Mar 24th, 2018
39
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # Install reddit, create a Reddit clone
- ## 1. Create a Ubuntu 14.04 VM with VirtualBox
- 1. Download Ubuntu 14.04 server edition
- 1. In VirtualBox, after creating a new VM with 4gb RAM and 30gb disk space,
- 1. Set networking to use a "Bridged Adapter"
- 1. Add a CD rom entry and select the Ubuntu 14 .iso
- 1. Boot the VM
- 1. In the Ubuntu installer, put "-VM" in the hostname when asked to choose a hostname
- 1. Choose user "reddit"
- 1. Choose to install "OpenSSH Server"
- 1. Complete Ubuntu installation.
- 1. Login and run `ifconfig` and note your ip address
- 1. If you forgot to install the openssh server, run `sudo apt-get install openssh-server`
- 1. You can now detach your VM or shut it down and restart in headless mode. You should only interact with it via SSH from your host for easy copy and paste, etc. Don't forget to shut down your VM before shutting down the host or you may corrupt files.
- 1. Don't use VirtualBox snapshots or bother backing up your VM. Instead push your work to github and consider the VM transient.
- ## 2. Update your host's hosts file to resolve "reddit.local" in your browser
- Add the ip you noted earlier to your hosts file along with domain `reddit.local`. This varies by OS.
- Once this is setup you can ssh into your VM easily with `ssh reddit@reddit.local`. Even more easily if you install your ssh key on the VM.
- Bonus: mount VM files for local editing. You can easily mount the VM's files as a drive on your host machine for easy editing and searching. Sshfs is a quick and easy approach, run `sshfs reddit@reddit.local:/home/reddit ~/vm`. You can unmount later with `fusermount -u ~/vm` to avoid crashing your editor when shutting down your VM. Caution: mounting too many directories/files with sshfs is slow, after reddit installation you can try mounting `/home/reddit/src/reddit` instead.
- ## 3. Install reddit
- SSH into your VM as user "reddit", and run:
- # WARNING: Never run an apt-get "do-release-upgrade" or you will break reddit. You must stay on Ubuntu 14.
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get install git
- # TODO: needs installer(s) and example.ini updates
- # git clone https://github.com/libertysoft3/reddit-ae.git
- git clone https://github.com/libertysoft3/reddit.git
- # TODO: change the next 2 commands if using "reddit-ae"
- sudo chmod +x reddit/install-reddit.sh
- sudo ./reddit/install/reddit.sh
- # NOTE: reddit has been installed outside of this repo, check ~/src/reddit. this is due to needing other git repos being checked out.
- # TODO - Refactor to use git submodules, no misdirection needed.
- # if weird make error about "less" restart the server and try again
- # Optional - install sample data
- cd ~/src/reddit
- reddit-run scripts/inject_test_data.py -c 'inject_test_data()'
- # NOTE: with sample data, an admin user "reddit" with password "password" is created (???)
- # protip: if you create your admin account first (step 4) you will have a generated comment history
- # Avoids an error with 'popular_sr_ids' on registration (custom feature)
- # TODO: does cron also need to be updated to include this? Also used for choosing /r/random.
- sudo start reddit-job-update_popular_subreddits
- ## 4. Configure reddit
- Make "yourself" an admin account:
- cd ~/src/reddit/r2
- nano development.update
- # edit this line: employees = reddit:admin
- # add: ", yourself:admin"
- make ini
- sudo reddit-flush
- # Create a reddit account in your host browser https://reddit.local
- # You should see the "turn admin on" link
- Increase PostgreSQL max_connections for greater Solr compatibility (87/100 in use at reddit idle without solr running?):
- sudo nano /etc/postgresql/9.3/main/postgresql.conf
- # edit: change max_connections = 100 to 150, save
- sudo service postgresql restart
- sudo reddit-restart
- ## 5. Optional: install Solr (for search)
- As user "reddit" run:
- sudo apt-get install tomcat7 tomcat7-admin software-properties-common
- # installs java, openjdk-7-jre-headless
- # TODO: Would tomcat6 be more performant?
- cd ~
- wget http://archive.apache.org/dist/lucene/solr/4.10.4/solr-4.10.4.tgz
- tar -xvzf solr-4.10.4.tgz
- sudo mv solr-4.10.4 /usr/share/solr
- sudo chown -R tomcat7:tomcat7 /usr/share/solr/example
- # Setup Solr, install Reddit schema
- sudo cp /usr/share/solr/example/webapps/solr.war /usr/share/solr/example/solr/
- sudo cp /usr/share/solr/example/lib/ext/* /usr/share/tomcat7/lib/
- sudo cp /usr/share/solr/example/resources/log4j.properties /usr/share/tomcat7/lib/
- sudo mv /usr/share/solr/example/solr/collection1/conf/schema.xml /usr/share/solr/example/solr/collection1/conf/schema.xml.bak
- sudo cp src/reddit/solr/schema4.xml /usr/share/solr/example/solr/collection1/conf/schema.xml
- sudo chown tomcat7:tomcat7 /usr/share/solr/example/solr/collection1/conf/schema.xml
- # Setup Tomcat for Solr
- sudo nano /usr/share/tomcat7/lib/log4j.properties
- # edit to set:
- solr.log=/usr/share/solr
- sudo nano /etc/tomcat7/Catalina/localhost/solr.xml
- # add content:
- <Context docBase="/usr/share/solr/example/solr/solr.war" debug="0" crossContext="true">
- <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/example/solr" override="true" />
- </Context>
- # have tomcat use port 8983, 8080 is taken by haproxy
- sudo nano /etc/tomcat7/server.xml
- # edit to set:
- <Connector port="8983" protocol="HTTP/1.1"
- # Solr is missing some required stuff:
- sudo touch /usr/share/solr/solr.log
- sudo mkdir /usr/share/tomcat7/temp
- sudo chown tomcat7:tomcat7 /usr/share/solr/solr.log
- sudo chown tomcat7:tomcat7 /usr/share/tomcat7/temp
- # verify tomcat all good (ignore warnings):
- /usr/share/tomcat7/bin/configtest.sh
- sudo service tomcat7 restart
- # any errors in here must be fixed
- sudo cat /var/log/tomcat7/catalina.out
- # verify working, these should return html pages:
- wget 127.0.0.1:8983
- wget 127.0.0.1:8983/solr
- Configure Reddit to use Solr for search:
- # as non-root user
- nano ~/src/reddit/r2/example.ini
- # EDIT: change: search_provider = cloudsearch to: search_provider = solr
- # EDIT: add below (solr port changed from default 8080 to 8983):
- solr_version = 4
- solr_search_host = 127.0.0.1
- solr_doc_host = 127.0.0.1
- solr_subreddit_search_host = 127.0.0.1
- solr_subreddit_doc_host = 127.0.0.1
- solr_port = 8983
- solr_core = collection1
- solr_min_batch = 500
- solr_query_parser =
- # since example.ini has changed
- cd ~/src/reddit/r2
- make ini
- # ???? sudo reddit-restart
- Add reddit content to Solr, verify working:
- cd ~/src/reddit/r2
- paster run run.ini -c 'import r2.lib.providers.search.solr as cs; cs.rebuild_subreddit_index()'
- paster run run.ini -c 'import r2.lib.providers.search.solr as cs; cs._rebuild_link_index()'
- ### Setup Solr cron jobs:
- TODO - install/reddit.sh copies upstart/* to /etc/init/
- TODO - in source put this/these in upstart/reddit-job-solr_subreddits.conf and reddit-job-solr_links.conf
- sudo nano /etc/init/reddit-job-solr_subreddits.conf
- # paste lines, save:
- description "Add new subreddits to Solr."
- manual
- task
- stop on reddit-stop or runlevel [016]
- nice 10
- script
- . /etc/default/reddit
- wrap-job paster run $REDDIT_INI -c 'import r2.lib.providers.search.solr as cs; cs.rebuild_subreddit_index()'
- end script
- and then...
- sudo nano /etc/init/reddit-job-solr_links.conf
- # paste lines, save:
- description "Add new posts to Solr."
- manual
- task
- stop on reddit-stop or runlevel [016]
- nice 10
- script
- . /etc/default/reddit
- wrap-job paster run $REDDIT_INI -c 'import r2.lib.providers.search.solr as cs; cs._rebuild_link_index()'
- end script
- and then...
- echo '# Solr search:' | sudo tee --append /etc/cron.d/reddit
- echo '*/3 * * * * root /sbin/start --quiet reddit-job-solr_subreddits' | sudo tee --append /etc/cron.d/reddit
- echo '* * * * * root /sbin/start --quiet reddit-job-solr_links' | sudo tee --append /etc/cron.d/reddit
- Tail /var/log/syslog to see the status of these and other jobs. Log files exist for each upstart job, e.g. /var/log/upstart/reddit-job-solr_rebuild_link_index.log. You can manually run upstart jobs, e.g. sudo start reddit-job-update_reddits
- ## References
- * https://github.com/reddit/reddit/tree/master/solr
- * http://webikon.com/cases/installing-apache-solr-4-7-multicore-on-ubuntu-12-04-and-tomcat7
- * https://drupal.stackexchange.com/questions/95897/apache-solr-4-6-0-installation-and-compatibility-with-drupal7/124038#124038
- * https://www.digitalocean.com/community/tutorials/how-to-install-solr-on-ubuntu-14-04
- * https://www.digitalocean.com/community/tutorials/how-to-install-solr-5-2-1-on-ubuntu-14-04
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
