Latest posts

Browse topics

How to Install Drupal 8 with Nginx, PHP-FPM 7.2, MySQL, phpMyAdmin on Ubuntu 18.04 - Linode Guide

In this article, you will learn how to setup Drupal 8 with Nginx, PHP-FPM 7.2, MySQL and phpMyAdmin on Ubuntu 18.04

For the following tutorial, I used very much the information from my previous guide with Ubuntu 16.04, but decided to rewrite it for Ubuntu 18.04 version as when I tried to setup my latest project about stock trading 0dtespxtrading.com  with Drupal 8.8.5  on Ubunut 16.04 machine an error from Drupal that PHP version shipped with Ubuntu 16.04   was outdated and instead of upgrading that box I decided to go with a new server from scratch, 

Prerequisites

  • Ubuntu 18.04 
  • Root privileges.

You can get a cheap VPS starting just $5/mo from Linode. That's what I did - bought a new nanode from Linode

Deploying server with Linode

Deploying server with Linode

Literally in couple of seconds the new server was up and running - that's what I love sticking with Linode for years

Follow basic security guide, see: Securing Your Server

I will use Putty for Windows to access SSH

Secure your server

Create the user, replacing example_user with your desired username. You’ll then be asked to assign the user a password:

adduser example_user


Add the user to the sudo group so you’ll have administrative privileges:

adduser example_user sudo

Disallow root logins over SSH. This requires all SSH connections be by non-root users. Once a limited user account is connected, administrative privileges are accessible either by using sudo or changing to a root shell using su -.

sudo nano /etc/ssh/sshd_config

Under # Authetification section change to

# Authentication: ...

PermitRootLogin no

Update the Ubuntu system

sudo apt-get update

Install Nginx and PHP-FPM

Install Nginx with the following apt command:

sudo apt-get install nginx -y

Next, install php7.0-fpm with php-gd extension that is required by Drupal core:

sudo apt-get install php7.2-fpm php7.2-cli php7.2-gd php7.2-mysql php7.2-xml -y

Configure Nginx and PHP-FPM

In this step, we will configure Nginx to use php-fpm to serve HTTP requests for PHP pages. Go to the php-fpm directory "/etc/php/7.0/fpm" and edit the "php.ini" file:

sudo nano /etc/php/7.2/fpm/php.ini

Un-comment the cgi.fix_pathinfo line and change the value to "0"

When using nano command you can use CTRL+W to locate that line. Once changed press CTRL+O to save changes and CTRL+X to exit from nano editor

Now we should modify the default Nginx virtual host configuration. Edit the "default" file and enable the php-fpm directive.

sudo nano /etc/nginx/sites-available/default

Un-comment  location ~ \.php$ section, so it look like this

location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}

CTRL+O and CTRL+X

Then test the Nginx configuration with the command "nginx -t" to ensure that it is valid:

nginx -t

If there is no error, restart nginx and the php-fpm service:

systemctl restart nginx
systemctl restart php7.2-fpm

PHP Info file (Optional)

Next, test that php-fpm is working properly with nginx by creating new php info file in the web directory "/var/www/html"

cd /var/www/html/
echo "<?php phpinfo(); ?>" > info.php

Visit the info.php file at the server IP  in a web browser.

Configure the VirtualHost for Drupal

We will install Drupal 8 in the directory "/srv/www/0dtespxtrading.com". Please replace my domain name in your installation with the domain name of the website that you want to use this Drupal installation for. So let's create the directory:

sudo mkdir -p /srv/www/0dtespxtrading.com/{public_html,logs}
sudo usermod -a -G www-data admin
sudo chown -R www-data:www-data /srv/www
sudo chmod -R 775 /srv/www
sudo nano /etc/nginx/sites-available/0dtespxtrading.com

Paste the Nginx configuration for Drupal 8:

server {
    server_name 0dtespxtrading.com;
    root /srv/www/0dtespxtrading.com/public_html; ## <-- Your only path $
    access_log /srv/www/0dtespxtrading.com/logs/access.log;
    error_log /srv/www/0dtespxtrading.com/logs/error.log;

    listen 80;
    listen [::]:80;


    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Very rarely should these ever be accessed outside of your lan
    location ~* \.(txt|log)$ {
        allow 192.168.0.0/16;
        deny all;
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/)\. {
        return 403;
    }

    location / {
        # try_files $uri @rewrite; # For Drupal <= 6
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # In Drupal 8, we must also match new paths where the '.php' appears in the middle,
    # such as update.php/selection. The rule we use is strict, and only allows this pattern
    # with the update.php front controller.  This allows legacy path aliases in the form of
    # blog/index.php/legacy-path to continue to route to Drupal nodes. If you do not have
    # any paths like that, then you might prefer to use a laxer rule, such as:
    #   location ~ \.php(/|$) {
    # The laxer rule will continue to work if Drupal uses this new URL pattern with front
    # controllers other than update.php in a future release.
    location ~ '\.php$|^/update.php' {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        include fastcgi_params;
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

    # Fighting with Styles? This little gem is amazing.
    # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
    location ~ ^/sites/.*/files/styles/ { # For Drpal >= 7
        try_files $uri @rewrite;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
}

CTRL+O and CTRL + X

The Drupal virtual host file has been created, now we have to activate it by creating a symlink to the file in the "sites-enabled" directory:

ln -s /etc/nginx/sites-available/0dtespxtrading.com /etc/nginx/sites-enabled/

Test the Nginx configuration and if there is no errors restart Nginx:

nginx -t
systemctl restart nginx

Install MySQL

sudo apt-get install mysql-server
​sudo mysql_secure_installation

Install phpMyAdmin

sudo apt-get install phpmyadmin

Hit ESC when the installation prompts you for auto-configuration, because there is no option for Nginx.

Make an easy accessible symlink

sudo ln -s /usr/share/phpmyadmin/ /srv/www/reinisfischer.com/public_html/phpmyadmin

​

Install and Configure Drupal

Enter the directory that we created earlier and download Drupal with wget. I'm using the latest Drupal 8.8.7]5. release as of April 23, 2020, make sure you are downloading latest version by visiting Drupal 8 download page and writing down the last numbers (version)

cd /srv/www/0dtespxtrading.com
sudo wget https://ftp.drupal.org/files/projects/drupal-8.8.5.tar.gz
sudo tar -xvzf drupal-8.8.5.tar.gz
sudo cp drupal-8.8.5/* public_html/ -R
sudo chown www-data:www-data public_html -R

Now visit your Drupal site in the web Browser, you should see following screen

Drupal 8 welcome screen

Drupal 8 welcome screen

Now, it's just time to connect database and set up your Drupal 8 website

April 2020 Dividend Income Report - $78.40

Welcome to the thirty-sixth (#36) dividend income report, covering earnings I've made from dividend-paying stocks and peer to peer lending in April 2020.

Last April we spent in a self-isolation (because of Covid-19) here in Georgia. Baby girl is doing her online class, learning about animals, shapes, continents, and even planets. Quite fascinating what a 21-month-old can do. Development is very rapid.

King Davids Tower (s) in Tbilisi

King Davids Tower (s) in Tbilisi

It was on the evening of April 27, 2020, I decided to switch glass (from the kit lens to telephoto) and make some photo for the month of April to put in the description for the monthly dividend income report.

From the perspective of the market, last April was quite good, we recovered some 15% from the lost value, but still are under the water. From the perspective of dividends - this was a complete disaster - most ot the dividends were trimmed, some cut down to 0. Before the World's health crisis is was planned to take about $230 in dividends last April, but we managed to book only $78.40.

That's one of the worst dividend months in years - the sad news, this is not over - it will take many months, if not years to recover.

Compared to the previous April in 2019, that is a decrease of -52.26% (-$85.84)

Options trades helped a little to offset the losses, but also were nothing impressive - I made some money with calls and puts, but lost some money with vertical spreads. At the end of the month, we were able to book $41.33 from options trades. 

For a now I have decided to pause my adventures with crypto options, but I made some $9.28 last month

When counted all together (dividends + options + crypto options), it seems I have made $129.01 in total last month. Effective income yield last April was 0.76% (about 9.12% annually) Which is humble for me, but anything positive in these times is good.

One of my monthly goals is to generate at least 2.5% income yield from a portfolio. Let's see, can I get on the track in the futures months (Spoiler alert - the only way I see this happen is from option trading

Interest income in April 2020

From the stocks and peer to peer lending I got following income last month:

Ticker

Earnings

EDI

€27.26

EDF

€21.33

Mintos

€8.09

RA

€7.81

NCV

€3.88

AWP

€3.76

Total EUR 71.83 / USD 78.40

In total there were 6 companies paying us dividend in April 2020 that 5 companies less than in April 2020

We didn't get payments this April from, NRZ (dividend will be paid in May, but is cut by 90%), PNNT (we still hold the stock, but our stock was sold on div ex-day back in March, so we didn't qualify for a dividend this April, hopefully, things will get better in July.

If things were at the pre-COVID-19, we would collect at least $138.45 from NRZ and PNNT, but we didn't.

Monthly income

I've been tracking my journey towards million dollars in a savings account since January 2017.  More than three years already. The result for 2020 is lagging behind

in 3 out of 4 months this year, the dividend income has been lower than in 2019

Monthly dividend Income chart as of April 2020

Monthly dividend Income chart as of April 2020

The cumulative dividend earnings for 2020 now are $657.55  which is exactly 18.27% from my goal of 2020 ($3,600). On average, it would ask me to generate $367.81 every month for the next 8 months to reach my goal. With 90% confidence, I'm saying this goal won't be reached this year.

2019 in Review and Financial Goals for 2020

Goals for April 2021

This is my favorite part of the reports - trying to forecast/set goals for the next year. But before setting a goal for 2020, let's see what I forecasted/said a year ago (April 2019)

When setting goals for April 2020, I will say I want to increase dividend income by at least $70 - it translates in $234. Let's keep an odd number. I like them. lol

Wow, a total failure. I wasn't' smart enough to build Covid-19 proof dividend portfolio and instead of an increase of $70, we are now experiencing a decrease of more than $80.

When setting goals for 2021 - I will say anything above $200 will be a great result. To get there it will ask a lot of smart investments and a lot of cash deployed

Rundāle Palace and Garden

Rundāle Palace  is one of the two major baroque palaces built for the Dukes of Courland in what is now Latvia, the other being Jelgava Palace. The palace was built in two periods, from 1736 until 1740 and from 1764 until 1768. It is situated at Pilsrundāle, 12 km west of Bauska.

The palace and its garden are among the top 10 destinations to visit in Latvia. 

We have been heading to Rundāle once in a while, when in Latvia, preferably in Summer.

Rundala palace and its garden

Rundala palace and its garden

In 1735 Duke of Courland Ernst Johann von Biron bought land in Rundāle with an old medieval castle in the territory of a planned summer residence. The old castle was demolished and construction after the design of Bartolomeo Rastrelli started in 1736.

Construction proceeded slowly because part of the materials and resources were transferred to the construction of Jelgava Palace, a project which was more important for the duke. Following Biron's fall from grace in 1740, the palace stood unfinished and empty until 1762 when Biron returned from his exile.

Under the supervision of Rastrelli its construction was finished in 1768. Johann Michael Graff produced lavish stucco decorations for the palace during this time. Ernst Johann von Biron loved the palace and moved there already in 1768. He often visited palace and spent summers there until his death in 1772. Son of an Ernst Johann duke Peter von Biron visited palace only a few times because unlike his father he preferred to spend summers in his Vircava manor.

Garden at Rundale place

Garden at Rundale place

The garden is really impressive. It can compete to the famous Keukenhof tulip fields in the Netherlands.

The palace is one of the major tourist destinations in Latvia. It is also used for the accommodation of notable guests, such as the leaders of foreign nations. The palace and the surrounding gardens are now a museum

Guest House Old Wall in Lagodekhi

Offering a barbecue and children's playground, Guest House Old Wall is situated in Lagodekhi.

Property is set within the historic walls of the old castle Lakuasti. Guests can enjoy the on-site bar. Free WiFi is available throughout the property and free private parking is available on site.

This was our first stay in Lagodekhi, during a recent trip to the region (September 2019), we arrived here after a nice and comfy stay at Akhasheni Wine Resort near Gurjaani. 

Guest House Old Wall in Lagodekhi

Guest House Old Wall in Lagodekhi

It was decided to use this guesthouse as a base to reach the Ninoskhevi waterfall. And seems the guest house is one of the top choices for travelers from all around the World to get there.

Rooms feature mountain or garden views. Guests can enjoy traditional Georgian dishes on site.

Interior inside guest house

Interior inside guest house

Nice and cozy. We were offered a duplex room, but as we were traveling with a toddler, we asked to switch our rooms and were presented room in the first floor.

During our one night stay here we met travelers from Germany, Israel. In the evening kid hosts made a supra for us in the outside garden.

Traditional Georgian supra in the evening

Traditional Georgian supra in the evening

Grilled mead, salads and cheese, really good.

3 Trades to Generate $200/mo Selling Naked Puts on Dividend Stocks

I revisited the $200-a-month idea with new examples and a closer look at risk. Read How to Sell Cash-Secured Puts on Dividend Stocks (A Safer Way).

Selling naked puts on dividend stocks is one of my favorite ways to generate income. I’ve been selling options since the end of March 2019. As a dividend investor, I find options one of the best inventions of our time.

Income from options regularly puts food on our family table, or at least buys some candy. I sell puts and calls, trade vertical spreads on the S&P 500 (SPX), and trade gold futures and other instruments. Most importantly, I have a lot of fun doing it.

I recently read an article about selling puts on Microsoft, BP, and XLF to generate $1,000 a month. The author estimated it would take about $46,100 to collect $1,020 in premium, or about 2.21% for the month.

I decided to try the same approach using three stocks I hold in our portfolio: AT&T, Pfizer, and Cisco Systems. Their dividend schedules help spread the income across the year.

Selling puts on AT&T (T)

AT&T share price as of February 7, 2020.
AT&T share price as of February 7, 2020.

AT&T is probably my favorite stock to sell options on. It’s in the S&P 500, it had raised its dividend for 34 consecutive years, and its dividend yield was among the highest in the index.

I’ve been selling puts on it since March or April 2019. I also hold the stock in my dividend portfolio, where it contributes a little income in February, May, August, and November.

In this example, a March 6 put with a $38 strike was quoted at about $0.49 per share. That’s $49 per contract, or about 1.28% against the $3,800 purchase obligation in less than 30 days. My simple annualized estimate was 15.36%. The break-even price was $37.51.

If AT&T finishes above $38 at expiration, I keep the premium and can decide whether to sell another one. Below the strike, I’d generally expect assignment if I still held the position at expiry. I could close or roll the put before assignment, or take the shares, collect dividends if declared, and consider selling covered calls. One contract represents 100 shares, so assignment at $38 requires $3,800 before the premium.

Selling puts on Pfizer (PFE)

Pfizer share price as of February 7, 2020.
Pfizer share price as of February 7, 2020.

Like AT&T, Pfizer is in the S&P 500. It was also in the Dow Jones Industrial Average and on the Dogs of the Dow list. Its dividend yield was above 3%, and it had raised the dividend for nine consecutive years.

Pfizer is one of the latest additions to our dividend portfolio. I started buying it for what I call the Partnership Fund. In practice, that means buying Pfizer stock once a month for my better half.

I’ve been selling puts on Pfizer since January 2020. It also contributes to our dividend income in March, June, September, and December.

A March 6 Pfizer put with a $38 strike was quoted at about $0.68 per share. That’s $68 per contract, or about 1.78% against a $3,800 purchase obligation in less than 30 days. My simple annualized estimate was 21.36%. The break-even price was $37.42.

Above $38 at expiration, the put would expire worthless. Below $38, I’d generally expect assignment if the position remained open. A roll is another trade, with its own cost and risk. If I take assignment, I need $3,800 to buy the 100 shares before counting the premium.

Selling puts on Cisco Systems (CSCO)

Cisco share price as of February 7, 2020.
Cisco share price as of February 7, 2020.

Cisco Systems is also in the S&P 500 and the Dow. Like Pfizer, it was on the Dogs of the Dow list. The yield was just under 2%. I’d have liked a little more, but selling puts and calls gave me another way to earn income from the same stock. Cisco had also increased its dividend for nine consecutive years.

I’ve been adding Cisco to our dividend portfolio since January 2020. We expected those payments to contribute to our income in January, April, July, and November.

A March 6 put at the $48 strike was quoted at about $1.21 per share. That’s $121 per contract, or about 2.52% against the $4,800 purchase obligation in less than 30 days. My simple annualized estimate was 30.24%. The break-even price was $46.79.

If Cisco finished above $48, I could keep the premium and decide whether to write another put. Below $48, I’d generally expect assignment on an open position at expiration. Taking assignment would mean buying 100 shares for $4,800 before counting the premium.

What the three examples add up to

The three quoted premiums add up to $238 against $12,400 in possible stock purchases. That’s about 1.9% for the period. The simple annualized figure of roughly 22.8% assumes I could repeat that result month after month.

For comparison, my 2020 estimates for owning 100 shares each were $208 in annual dividends from AT&T, $152 from Pfizer, and $140 from Cisco. That’s $500 before tax, or about 4% against $12,400. The put premiums cover one set of trades, while those dividends were estimated for a whole year. The stock price can fall well below the break-even price, and a put can be assigned before expiration.

If I’m already holding the shares for dividends, I can also look at selling covered calls. That’s a subject for another article.