I'm working on a haskell web app using yesod that I eventually want to deploy to EC2, can someone recommend an AMI that has a recent haskell platform and a git client install-able from the repositories?
If you look at Michael Snoyman's setup script here, it contains the steps he used to get an EC2 instance going on a Ubuntu AMI.
https://github.com/yesodweb/benchmarks/blob/master/setup.sh
I also have Yesod running from source on Amazon Linux. It takes a few hours to build everything but I think any of the standard boxes with at least 8G of memory should do it (otherwise GHC can't link). This is how I did it:
# install what packages are available
sudo yum --enablerepo=epel install haskell-platform git make ncurses-devel patch
# make and install ghc
wget http://www.haskell.org/ghc/dist/7.0.4/ghc-7.0.4-src.tar.bz2
tar jxf ghc-7.0.4-src.tar.bz2
rm ghc-7.0.4-src.tar.bz2
cd ghc-7.0.4
./configure
make -j 4
# wait a few hours
sudo make install
cd
rm -rf ghc-7.0.4
# make and install haskell-platform
wget http://lambda.haskell.org/platform/download/2011.4.0.0/haskell-platform-2011.4.0.0.tar.gz
tar zxf haskell-platform-2011.4.0.0.tar.gz
cd haskell-platform-2011.4.0.0
./configure
make -j 4
sudo make install
cd
rm -rf haskell-platform-2011.4.0.0
You shouldn't compile on an EC2 instance. Choose a generic AMI like Ubuntu, and perform the compile on a local computer, then upload the static binary to EC2.
Related
How do I install Postgresql 11 on Amazon Linux 2018.03 (specifically, not AMZ Linux 2) on Elastic Beanstalk?
I want to install a package and not manually build a binary. If an autoscale machine boots and has to build the entire PG binary, it'll take significantly longer on a t2/t3.micro.
I'm looking for pg_dump.
[Edit] Making more verbose, explain why building does not work for my situation.
The key was the PGDG is no longer available to Amazon Linux's yum since 9.3 so the individual pieces must be installed.
# Remove old Postgres
yum remove -y postgresql postgresql-server
# Install Postgres 11
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-libs-11.4-1PGDG.rhel6.x86_64.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-11.4-1PGDG.rhel6.x86_64.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-server-11.4-1PGDG.rhel6.x86_64.rpm
[edit]
Replace the 11.4 in each link above with any version you need available at https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/
sudo yum update
sudo amazon-linux-extras install postgresql11
Looks like there's no PostgreSQL 11 pre-built binary distribution for Amazon Linux. The way I solve it was to build from source code:
wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz
tar zxvf postgresql-11.5.tar.gz
cd postgresql-11.5
./configure --without-readline
make
make install
By default, it will install pg_dump into /usr/local/pgsql/bin/pg_dump.
This is an extended version of #nitsujri answer. I can't comment their comment, so I will create new answer here.
Install prerequisites:
sudo yum install readline-devel
sudo yum group install "Development Tools"
Download PostgreSQL source code and install the distro:
wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz
tar zxvf postgresql-11.5.tar.gz
cd postgresql-11.5
./configure
make
sudo make install
Add this line to your ~/.bashrc. After that relogin to an EC2 instance.
export PATH=/usr/local/pgsql/bin:$PATH
I own a dedicated linux server from 1&1. I have SFTP and SSH access. I would like to know if it is possible to install node.js on my server.
I already tried to install it one week ago but I failed. The downloading and extraction worked, so the folder is on my server. I did :
cd ~
wget http://nodejs.org/dist/latest/node-v11.1.0.tar.gz
tar xvf node-v11.1.0.tar.gz
mv node-v11.1.0 nodejs
But this part failed :
cp nodejs/bin/node ~/bin
cd ~/bin
ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm
On the first instruction, there is an error : cp : cannot stat 'nodejs/bin/node': No such file or directory
I tried this too :
cd nodejs
./configure
make
make install
(All instructions are from tutorials)
The instructions are you following are for a precompiled bundle for Linux.
http://nodejs.org/dist/latest/node-v11.1.0.tar.gz is the URL to a source code bundle.
Download the compiled bundle for your system instead.
Your best bet may be to look for distribution-specific instructions. Most modern package managers will have an install option for Node and there are great options 3rd parties like Nodesource as well.
For instance, here's a DO howto for installing on Ubuntu 18.04. It lists 3 different methods for install, each of which would work from an SSH session.
If you let us know what distribution and version you are running, we may be able to help you more specifically.
If you don't know, you can try one of these commands to check:
$ hostnamectl
or
$ less /etc/issue
I'm trying to deploy a Yesod app to an Ubuntu server using Keter. So far this is what I've done:
Install Keter on the server using the provided setup script
wget -O - https://raw.github.com/snoyberg/keter/master/setup-keter.sh | bash
Run yesod keter to create a bundle on my dev machine (running OS X Mavericks)
scp the *.keter file into /opt/keter/incoming on the server
At this point, I think I should be able to go to my domain and have the app working, but I'm seeing a "Welcome to nginx" page instead. Additionally, all I have in /opt/keter/log/keter/current.log is:
2014-05-10 18:21:01.48: Unpacking bundle '/opt/keter/etc/../incoming/DoDeployTest.keter'
And I think I should have lines about starting a process and loading an app.
What do I need to do to deploy Yesod with Keter? Is there a good tutorial covering this (so far alot of the ones I'm reading seem somewhat outdated based on not mentioning useful things like yesod keter; hard to say though).
I'm pretty new to Haskell/Yesod/Keter/Sysadmin work so any help is appreciated.
Appendix:
Github repo of the Yesod project (Its vanilla yesod init w/ postgres + configuring the keter.yaml file)
Keter.yaml file:
exec: ../dist/build/DoDeployTest/DoDeployTest
args:
- production
host: "http://www.yesodonrails.com"
postgres: true
root: ../static
To ensure the maximum level of success possible, I would strongly advise you to compile and run both Keter and your Yesod application on the same platform. The recommendation is also to compile your application on a different machine from the one you're deploying on, since GHC compilation is very resource intensive. It looks like you're already doing this (albeit compiling on OS X and deploying on an Ubuntu server, which is not going to work, as described in response to your own answer).
My recommendation would be to use Docker containers to ensure consistent environments. I have a GitHub project containing a number of Dockerfiles I've been working on to address this and I'll describe roughly what they do here. Note that this GitHub project is still a work in progress and I don't have everything absolutely perfect yet. This is also similar to the answer I gave to this question.
keter-build:
FROM haskell:latest
RUN apt-get update && apt-get install -y \
git
RUN mkdir /src
RUN cd src && \
git clone https://github.com/snoyberg/keter && \
cd keter && \
git checkout e8b5a3fd5e14dfca466f8acff2a02f0415fceeb0
WORKDIR /src/keter
RUN cabal update
RUN cabal install keter
This configures a container that can be used to build the keter binary at a given revision from the Keter GitHub project.
keter-host:
FROM debian
RUN apt-get update && apt-get install -y \
ca-certificates \
libgmp-dev \
nano \
postgresql
COPY artifacts/keter /opt/keter/bin/
COPY artifacts/keter-config.yaml /opt/keter/etc/
EXPOSE 80
CMD ["/opt/keter/bin/keter", "/opt/keter/etc/keter-config.yaml"]
This container is a self-contained Keter host. You should ensure that the keter binary built in the keter-build container is available in the artifacts directory so that the COPY artifacts/keter /opt/keter/bin/ instruction copies it into the image.
yesod-env:
FROM haskell:latest
RUN apt-get update && apt-get install -y \
ca-certificates \
git \
nano \
wget
RUN echo 'deb http://download.fpcomplete.com/debian/jessie stable main' > /etc/apt/sources.list.d/fpco.list
RUN wget -q -O- https://s3.amazonaws.com/download.fpcomplete.com/debian/fpco.key | apt-key add -
RUN apt-get update && apt-get install -y \
stack
This is a container for building the Yesod app. Note that this Dockerfile is incomplete and haven't got it to clone the app's source code and build it yet. However, this might get you started.
Note that all three containers are ultimately based off the same debian Docker base image, so that binaries produced in each container will have a good chance of being valid in other containers. Some of my work was inspired by Dockerfiles designed by thoughtbot.
Ah, so based on the advice from the blog post introducing Keter, I tried to run the executable inside the *.keter file manually. Doing so yielded the message "cannot execute binary file". I suspect this is because I was compiling on a Mac originally, and deploying to an Ubuntu instance (I had this same problem trying to deploy to Heroku).
Process for discovering this (might be slightly inaccurate):
cp /opt/keter/incoming/DoDeployTest.keter /tmp
cd /tmp
mv DoDeployTest.keter DoDeployTest.tar.gz
gunzip DoDeployTest.tar.gz
tar xvf DoDeployTest.tar
# run executable
/dist/build/appname/appname
I am not able to install the pdftk on Amazon Linux AMI release 2012.03. pdftk requires gcj2.14 and amazon ami provides gcj2.12 package. If I try to install gcj2.14 getting conflicts with the existing gcj package. Please suggest a way to install pdftk without any need to upgrade amazon ami linux as my application is already setup and running there.
Your help will be appreciated
Inspired by #marcus and his github repo, I just did this:
sudo wget -O /usr/lib64/libgcj.so.10 https://github.com/lob/lambda-pdftk-example/raw/master/bin/libgcj.so.10
sudo wget -O /usr/bin/pdftk https://github.com/lob/lambda-pdftk-example/raw/master/bin/pdftk
chmod a+x /usr/bin/pdftk
Works like a charm.
As you probably don't want to pollute your production image with all dependencies pdftk requires - one way is to build pdftk somewhere else and deploy it to e.g. through S3.
Following is steps should get you started. Copy and paste from history so should show steps needed.
Pick up RedHat instance from AWS (or local Centos 6)
sudo su -
yum install gcc
yum install gcc-java
yum install gcc-c++
cd /tmp/
wget http://pkgs.repoforge.org/pdftk/pdftk-1.44-2.rf.src.rpm
rpm2cpio pdftk-1.44-2.rf.src.rpm | cpio -idmv
unzip pdftk-1.44-src.zip
cd pdftk-1.44-dist/
cd pdftk
make -f Makefile.Redhat
find / -iname libgcj.so.10.0.0
mkdir -p /tmp/pdftk
cp pdftk /tmp/pdftk
find / -iname libgcj.so.10.0.0
cp /usr/lib64/libgcj.so.10.0.0 /tmp/pdftk
cd /tmp/
tar cvzf pdftk.tar.gz pdftk
Make sure you copy tar package content in target machine (Linux AMI) as follows
libgcj.so.10.0.0 install to /usr/lib64
ls -alh /usr/lib64/libgcj.so.*
lrwxrwxrwx 1 root root 27 Sep 6 06:39 /usr/lib64/libgcj.so.10 -> /usr/lib64/libgcj.so.10.0.0
-rwxr-xr-x 1 root root 47M Sep 6 06:38 /usr/lib64/libgcj.so.10.0.0
I just used to S3 bucket to transfer file:
/usr/bin/s3cmd --force get s3://<your-bucket>/rpm/pdftk.tar.gz /tmp/
pushd /tmp
/bin/tar xzf pdftk.tar.gz
/bin/cp pdftk/pdftk /usr/bin/
/bin/cp pdftk/libgcj.so.10.0.0 /usr/lib64/libgcj.so.10.0.0
/bin/ln -s /usr/lib64/libgcj.so.10.0.0 /usr/lib64/libgcj.so.10.0
/sbin/ldconfig
popd
Very old post, but I've been looking into ways to get pdftk installed on the Amazon distro (which is what the OP is using). Here's a response from an Amazon rep:
GCJ is not supported on the Amazon Linux AMI, which is why you are
running into this problem.
In the interest of getting you moving forward as quickly as possible
on an EC2 instance that is RPM based, I'd recommend that you give
Fedora a try, because pdftk is packaged in their repositories.
Thank you for using EC2, and I hope this suggestion helps you out.
https://forums.aws.amazon.com/thread.jspa?threadID=96919
I want to install a mysql workbench binary locally on my linux machine because I don't have sudo rights. I did this when I installed python using --prefix. Can this also be done with mysql workbench?
Yes, you can, provided that you are willing to compile Workbench from sources. You are advised however that you'll need sudo rights to install its compilation dependencies. Here are the steps:
Download Workbench's sources from the official download site. You should download the version tagged "Generic Linux (Architecture Independent), Compressed TAR Archive".
Uncompress the downloaded source file. From the linux terminal:
$ tar -zxvf mysql-workbench-whatever.tar.gz
Move to the directory with Workbench's source code:
cd mysql-workbench-whatever
Read the INSTALL file located in this directory to find out the required packages that you would need to install in order to compile Workbench. For Ubuntu here's the command to install them:
$ sudo apt-get install build-essential autoconf automake libtool libzip-dev libxml2-dev libsigc++-2.0-dev libglade2-dev libgtkmm-2.4-dev libglu1-mesa-dev libgl1-mesa-glx mesa-common-dev libmysqlclient15-dev uuid-dev liblua5.1-dev libpixman-1-dev libpcre3-dev libgnome2-dev libgtk2.0-dev libpango1.0-dev libcairo2-dev python-dev libboost-dev
Run autogen.sh with the path to where you want Workbench installed:
$ ./autogen.sh --prefix=~/bin/wb52
(The above command will get your Workbench's binaries in the directory bin/wb52 within your home directory once compiled). Just change the destination dir to whatever you like.
Compile and install MySQL Workbench:
$ make install
This will take some time (maybe half an hour depending on your system). If you have more than one CPU core available you should use, for instance:
$ make -j3 install
and this will use three cores for compilation (adjust the number of cores to whatever you find reasonable for your system).
Once compiled you can run Workbench's executable that will be located inside a bin directory within the path you set in step 5.
Have a lot of fun!