sudo apt-get install -y openssl libreadline6-dev git-core zlib1g libssl-dev libpq-dev
sudo apt-get install -y libyaml-dev libsqlite3-dev sqlite3
sudo apt-get install -y libxml2-dev libxslt-dev
sudo apt-get install -y autoconf automake libtool bison
cd /usr/src/ sudo wget http://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.gz sudo tar -xvzf ruby-2.4.0.tar.gz cd ruby-2.4.0 sudo ./configure --enable-shared
--with-openssl-dir=/usr/bin--disable-install-doc --disable-install-rdoc --disable-install-capi sudo make install
Before compile: Thu 19 Jan 05:11:11 BRST 2017
After compile: Thu 19 Jan 05:30:19 BRST 2017
It takes around 20 minutes to compile.
Installing Rails without the docs:
sudo gem install rails --no-ri --no-rdoc
you can make it default o not install rubygems documentation:
sudo echo "gem: --no-ri --no-rdoc" >> ~/.gemrc
Installing the PostgreSQL:
Step 1: Update and Install Packages
First, go ahead and update your Pi's packages:
sudo apt-get update
Once this is finished, you can run the following command to grab and install PostgreSQL:
sudo apt-get install postgresql-9.4
It may take a bit to complete, but once it's done, confirm the installation:
You should get a result like this:
pi@raspberrypi:~ $ which psql /usr/bin/psql
You should now have a fully functional PostgreSQL database server on your Pi! It's that easy!
In the next steps, we'll configure this server to allow access from external clients (i.e. other computers running a server manager, such as pgAdmin).
Step 2: Modify Configuration
By default, PostgreSQL is configured to only allow access to it's databases from the same machine. This is fine for testing, but our aim is to have a centralized, locally accessible database server. To open access for other machines, we'll need to modify a few configuration files.
First, let's modify the
pg_hba.conf file. This controls client authentication and is, by default, configured to only allow local access. Before we make any edits, however, we'll want to create a backup of our default configuration:
sudo cp /etc/postgresql/9.4/main/pg_hba.conf /etc/postgresql/9.4/main/pg_hba.conf.bak
Then, enter the following to open the file for editing:
sudo nano /etc/postgresql/9.4/main/pg_hba.conf
At the end of this file, enter the following line:
host all all 192.168.0.0/24 md5
This will allow access from users on our local network (i.e. any client with a 192.168.0.* IP address.
NOTE: You may need to change the first part (192.168) if your router assigns a different network address (like 129.144).
To save your changes to the
pg_hba.conf file, enter
Next, we'll need to modify the main
postgresql.conf configuration file to allow access from IP addresses other than localhost. But first, make a backup of this file before proceeding:
sudo cp /etc/postgresql/9.4/main/postgresql.conf /etc/postgresql/9.4/main/postgresql.conf.bak
sudo nano /etc/postgresql/9.4/main/postgresql.conf
And change the following line:
listen_addresses = 'localhost'
listen_addresses = '*'
This will allow the PostgreSQL server to accept connections from any IP address. In combination with the changes we made to the
pg_hba.conf file, this should allow any clients on the local network access to the server, while still protecting from outside requests. As explained on StackOverflow:
listen_addresses controls which IPs the server will answer on, not which IPs the server will permit connections to authenticate from. It's entirely reasonable and normal to use listen_addresses '*' so the server will accept incoming connections on any ip assigned to an interface on the postgresql server host, while using pg_hba.conf to control access at a finer grained level for which IPs the server will accept logins from for specific databases and users.