Installing reddit on a Vagrant Ubuntu 12.04 box

empty reddit screenshot

These instructions assume you have some experience with Vagrant and using Ubuntu from the command line. It should take less than 20 minutes to get your own reddit install up to play with.

My environment:

  • Windows 7
  • Vagrant 1.2.2
  • VirtualBox 4.2.10
  • Git Bash as a terminal

Initial Setup

Start setting up a Vagrant machine. Lines like this in your .Vagrantfile give you a good box to start with:

  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

In Git Bash, run:

vagrant up

Let the box start up, then run:

vagrant ssh

to log in. Once you are in the virtual machine, run:

sudo apt-get update

to get the latest lists of available packages. The installation script will fail without it.

Installing reddit

Follow the instructions here: https://github.com/reddit/reddit/wiki/reddit-install-script-for-Ubuntu. I used reddit.local as a host name. The install script will spend a few minutes downloading packages, installing applications, and configuring them as reddit requires.

One error

There’s one hiccup in the process. The install scripts wants to setup the reddit DB in a utf8 locale. Ubuntu is set to use en_US though. The script stops with an error like this:

ERROR:  encoding UTF8 does not match locale en_US
DETAIL:  The chosen LC_CTYPE setting requires encoding LATIN1.
CREATE ROLE
+ sudo -u postgres psql reddit
psql: FATAL:  database "reddit" does not exist

To get around this, stop the default PostgreSQL cluster, and start a new one with the correct locale for the reddit install script. I learned this from Ask Ubuntu.

sudo pg_dropcluster --stop 9.1 main
sudo pg_createcluster --locale=en_US.utf8 --start 9.1 main

And start running the install script again with:

sudo ./install-reddit.sh

The script should make it all the way through to more instructions this time.

Viewing your Personal reddit

Update your Windows host file to include the line:

127.0.0.1       reddit.local

This tells your browser to connect to your own computer instead of trying to find reddit.local in the DNS. You may need to grant your Windows user permission to edit the file, or use an administrator account to edit it.

You will also have to enable port connections to port 80 in your .Vagrantfile. Run:

exit

in the terminal to exit your VM and go back to your Windows machine. Add this line to the .Vagrant file:

config.vm.network :forwarded_port, guest: 80, host: 8080

In the terminal, restart the Vagrant box by running:

vagrant reload

After it starts, visit

http://reddit.local:8080

in a Windows-based web browser to see your reddit.

Next steps

You can install the default data as suggested in the instructions. After that, you’ll probably ask “How to login as an admin?”, which is answered along with many other questions here: https://github.com/reddit/reddit/wiki/FAQ

Policy file for WordPress W3TC and S3-based CDNs

If you are using S3 as a CDN, you will need to give WordPress’ W3TC plugin access to your AWS account so it can upload files to S3 on behalf of you. The smart way to do this is to create a new AWS user who can only access what they need for W3TC to do its job. Who wants to store the keys to their whole AWS account in their WordPress based site? If that information is retrieved by a hacker, they could do tons of damage. If they only gain access to your site’s specific bucket, there is less damage to be done.

Here’s what a policy file will look like for a S3 user for W3TC. Unfortunately it does need the ability to list all your buckets, but all the other read/write/delete permissions can be limited to the site-specific bucket.

{
    "Statement": [
        {
            "Action": "s3:*",
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::bucketnamehere",
                "arn:aws:s3:::bucketnamehere/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": "s3:ListAllMyBuckets",
            "Resource": "arn:aws:s3:::*"
        }
    ]
}

If you give the user incorrect permissions, you will see ‘permission denied’ errors when W3TC tries to run the functions S3::listBucket and S3::putObject.

Similar post: Granting access to a single S3 bucket using Amazon IAM

Fast way to get Android App Screenshots (4.0 and up)

  1. Start AirDroid
  2. On your device, press the volume down and power button at the same time to take a screenshot
  3. Open and occasionally refresh the photos screen in AirDroid. You can delete screenshots that don’t make the cut right from here, and find out when ones to retake If you need to take more screenshots, GOTO STEP 2.
  4. Once the all the screenshots are taken, select the good ones in AirDroid, and use the download button to transfer them off your device in one compressed archive.

Depending on your USB connection, downloading the images from AirDroid in 1 archive may be faster than selecting them all in your OS’s file browsers and having them move over the cable 1 by 1.