Categories
DevOps

ngrok with homestead

ngrok http -host-header=rewrite site.dev:80

Reference: https://laracasts.com/discuss/channels/servers/homestead-ngrok

Categories
DevOps

Start Mailcatcher on a virtual machine

Stop mailcatcher if it’s running:

sudo lsof -nP -iTCP:1025 -sTCP:LISTEN
sudo kill [PID]

Start mailcatcher:

mailcatcher --ip=0.0.0.0

Categories
DevOps

Vagrant Error on Windows: unknown encoding name – CP720

Solution:

chcp 1252

This is caused by your current terminal as it is using a codepage (encoding) that is not supported by Ruby. Codepage 720 is Arabic characters used by MS-DOS back in the day and seems Ruby do not have a translation table for it.

Reference: https://stackoverflow.com/questions/22815542/rails4-unknown-encoding-name-cp720

Categories
DevOps

Install Mailparse extension on PHP 7.0 + Apache + Vagrant (Ubuntu)

1. SSH into your server (Vagrant, Whatever)

vagrant ssh

# or

ssh [email protected]

2. Follow the following instruction:

cd /tmp

apt-get install php7.0-dev

pecl download mailparse

tar xvzf mailparse-3.0.2.tgz

cd mailparse-3.0.2

phpize

./configure

sed -i \
  's/^\(#error .* the mbstring extension!\)/\/\/\1/' \
  mailparse.c

make

make install
echo "extension=mailparse.so" > \
  /etc/php/7.0/fpm/conf.d/30-mailparse.ini

service php7.0-fpm reload
echo "extension=mailparse.so" > \ /etc/php/7.0/mods-available/mailparse.ini 
ln -s /etc/php/7.0/mods-available/mailparse.ini /etc/php/7.0/cli/conf.d/30-mailparse.ini 
ln -s /etc/php/7.0/mods-available/mailparse.ini /etc/php/7.0/cli/conf.d/30-mailparse.ini

Source: https://stackoverflow.com/questions/35793216/installing-mailparse-php7-mbstring-error

Although I ended up adding manually (last step) maybe this can be a future reference for myself or any other developer.

Categories
DevOps

Certbot + Cloudflare

1. Install Certbot

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-apache

more: https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx

2. Make cloudflare.ini

Get your API key from: https://dash.cloudflare.com/profile

# In ~/cloudflare.ini
# Cloudflare API credentials used by Certbot
dns_cloudflare_email = [email protected]
dns_cloudflare_api_key = 0123456789abcdef0123456789abcdef01234567

Secure cloudflare.ini file:

chmod 600 cloudflare.ini

more: https://certbot-dns-cloudflare.readthedocs.io/en/stable/#credentials

3. Install Cloudflare plugin

sudo apt-get install certbot python3-certbot-dns-cloudflare

code: https://github.com/certbot/certbot/tree/master/certbot-dns-cloudflare
more:
https://certbot.eff.org/docs/using.html#plugins

4. Activate SSL

Change amirmasoud.me and www.amirmasoud.me to your domains:

certbot certonly \
  --dns-cloudflare \
  --dns-cloudflare-credentials ~/cloudflare.ini \
  -d amirmasoud.me \
  -d www.amirmasoud.me

more: https://certbot-dns-cloudflare.readthedocs.io/en/stable/#examples