Blynk server on AWS Linux tutorial video

I made a video on how to deploy a Blynk server on AWS Linux. I hope this helps the community.

Enjoy!

5 Likes

thats great - recon you can do one for Google Cloud as well ? Although similar to AWS there are differences that community could find of use.

I also added postgresql capabilities. Here are all the commands. Replace the hostname, email address and password with your info. This works without any errors on AWS AMI Linux (see video).

sudo yum remove -y java-1.7.0-openjdk.x86_64
sudo yum -y update
sudo yum install -y java-1.8.0 wget 
wget https://github.com/blynkkk/blynk-server/releases/download/v0.40.2/server-0.40.2-java8.jar
mkdir Blynk

#Get Let's Encrypt certificate
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo yum install -y augeas-libs gcc libffi-devel openssl-devel python27-tools system-rpm-config
sudo  ./certbot-auto certonly -n --agree-tos --email your@emailaddress.com --standalone -d myserver.domain.com --debug


sudo chmod 755 /etc/letsencrypt/live/
sudo chmod 755 /etc/letsencrypt/archive/

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 9443
sudo service iptables save

echo "mail.smtp.username=your@emailaddress.com" > mail.properties
echo "mail.smtp.auth=true" >> mail.properties
echo "mail.smtp.starttls.enable=true" >>  >> mail.properties
echo "mail.smtp.host=smtp.gmail.com" >>  mail.properties
echo "mail.smtp.port=587" >>  mail.properties
echo "mail.smtp.password=YOURPASSWORD" >>  mail.properties
echo "mail.smtp.connectiontimeout=30000" >>  mail.properties
echo "mail.smtp.timeout=120000" >>  mail.properties

echo "server.ssl.cert=/etc/letsencrypt/live/myserver.domain.com/fullchain.pem" > server.properties
echo "server.ssl.key=/etc/letsencrypt/live/myserver.domain.com/privkey.pem" >> server.properties
echo "server.ssl.key.pass=" >> server.properties
echo "enable.db=true" >> server.properties
echo "enable.raw.db.data.store=true" >> server.properties
	
(crontab -l 2>/dev/null; echo "@reboot java -jar server-0.40.2-java8.jar -dataFolder /home/ec2-user/Blynk &") | crontab -

wget https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/core/src/main/resources/create_schema.sql
wget https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/core/src/main/resources/reporting_schema.sql
mv create_schema.sql /tmp
mv reporting_schema.sql /tmp

sudo yum -y install postgresql96-server postgresql96 postgresql96-contrib
sudo service postgresql96 initdb
sudo sed -i.bak -e 's/ident$/password/' /var/lib/pgsql96/data/pg_hba.conf
sudo service postgresql96 start
sudo chkconfig postgresql96 on
sudo su - postgres
psql
\i /tmp/create_schema.sql 
\i /tmp/reporting_schema.sql
\q
exit
sudo reboot

Thanks.

You don’t need this. Blynk server already has this feature. You need just correctly set server.properties and certificates will be automatically generated on initial start and renewed when necessary.

Automatic would be better and I really like that it takes care of the renewal.

When I first challenged myself to figure all this out I had problems with blynk server registering the certificates automatically so I just did it via the manual way. I’ve learned a lot since then and I’m pretty sure the issues I had when I started were FQDN-related. I’ll try doing it the automatic way and report back any issues or feedback that can help others.

The mentioned method prevent automatic letsencrypt update, as this proces also uses port 80 and 443, which are redirected to 8080 and 9443.
How do you handle renewal of certificate?