Creating a LAMP Server for WordPress

I want to host a web server at home. Why do you ask? I say, Why not? This will be a fun project. Ultimately, I want a website for my family. A single location on the Internet where you can come and learn about the Helmers family. To do this, I am going to install a LAMP (Linux Apache MySQL PHP) server onto a Raspberry Pi.

I’m ultimately choosing Apache as the web server because it is so widely supported. There is a ton of knowledge about this program out there, and it’s a bit more user-friendly than nginx, another popular web server (At least in my experience). Alright, let’s get to it!

Steps to Follow:
  1. Setup Raspberry Pi
  2. Install needed applications except for WordPress
  3. Setup MySQL
  4. Install WordPress
  5. Configure Apache
  6. Configure WordPress
1. Setup Raspberry Pi:

Along with the standard Raspbian Lite install, I also suggest installing ddclient for DynamicDNS. These programs are further explained in their own respective posts.

2. Install needed applications:

Use the following command:

sudo apt-get install apache2 php7.0 php7.0-curl php7.0-gd php7.0-imap php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-xmlrpc libapache2-mod-php7.0 mysql-server -y

While installing MySQL, you will need to create a password.

3. Setup MySQL:

Now we will create a database where WordPress will store its data.

The username for MySQL is “root”. Type:

sudo mysql -uroot -p

Then enter the password you created during installation, and you will be in MySQL. Now create the database.

Create a database

create database WordPress;

Create a dedicated user for the database. use ‘root’ as the username.
GRANT ALL PRIVILEGES ON WordPress.* TO root@”localhost” IDENTIFIED BY ‘password’’;

Exit MySQL by typing ‘exit’

4. Install WordPress:
sudo mkdir /var/www/html/wordpress
cd /var/www/html/wordpress
sudo rm *
sudo wget http://wordpress.org/latest.tar.gz

Then we will extract the content via the command “tar”.

sudo tar xzf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz

A new folder will be created during the extraction, the “wordpress” folder. We also removed the now useless installation files.

5. Configure Apache:

We will ensure that Apache has access to the file. To do this, run the following command:

sudo chown -R www-data /var/www/html/wordpress

You’ll need to enable Apache’s rewrite mod:

sudo a2enmod rewrite

You’ll also need to tell the virtual host serving the site to allow requests to be overwritten.

Edit the Apache configuration file for your virtual host:

sudo nano /etc/apache2/sites-available/000-default.conf

Make sure the top of the document looks like this:

<VirtualHost *:80>
<Directory "/var/www/html/wordpress">
AllowOverride All
</Directory>

All you have to do now is restart the Apache server with the following command:

sudo service apache2 restart
6. Configure WordPress:

First connection to WordPress on your Raspberry Pi

Walk through install steps that WordPress provides, it is pretty self-explanatory. When asked for database information, use the WordPress database created earlier, and user ‘Root’ with the password you created.

Once you are done there, you have a functioning website!

Now, to make sure that the domain name you want to be attached to it is correct, Click “Run Install”

Fill out the info as WordPress asks for it.

Go to Settings then Permalinks. This will make your site more user-friendly.

Select the Post name option and click Save Changes.

Make sure to update your DNS settings with your registrar and then go to the ‘Settings’ tab on the left of your WordPress site. Update the ‘WordPress Address’ and ‘Site Address’ to reflect your domain name. This should allow you to access your site from the domain you created. In this case, helmershomestead.org.

Takeaways and future thoughts

Unexpected problems:
After running ‘sudo service apache2 restart’ in step 5, I received the following error:

Job for apache2.service failed because the control process exited with error code.
See “systemctl status apache2.service” and “journalctl -xe” for details.

I realized that on this Raspberry Pi I was running my PiHole on. This means that Port 80 (http) is beign used by the Lighttpd server that the PiHole is using. Using the command
grep -ri listen /etc/apache2
I was able to see what ports Apache was listening to. Sure enough, Port 80 was being heard. So, I went into the following files and changed them all to be listening to Port 8080. When the time comes, I will have my router forward any external Port 80 requests to Port 8080 on my Raspberry Pi.

I have not solved this issue yet. Having identified the problem, I can work towards a solution. In the meantime, I fired up another Pi to install WordPress on.

I also struggled with SSL not working. My original ambition was to have this page be encrypted, but it’s taking a bit for me to figure out how to to add SSL to it.

Future Concerns:
I suppose my ISP could get irritated that I’m hosting my little webserver, but I’m not too worried. That’s a bridge all cross when I come to it. My other concern is that my Raspberry Pi is too weak to really power my website. Time will tell on that one.

Future Enhancements:
I want to enhance the website and maybe someday move it to a better server. This is mostly just a fun project for me now. Here’s a short list of what I would like to do to this page:

– Add SSL encryption
– Make a subdomain for NextCloud

I received a much help from the authors of the following sites:
https://www.raspberrypi.org/learning/lamp-web-server-with-wordpress/

Upgrade that old wired printer

This is for my father, who has an old wired Brother Printer/copier.

Do you have a printer at home that works well, but you have to plug into it with a USB cable to print? Me too. My wife, Kristin, has a fantastic Brother printer from college. It’s fast and quite the workhorse. But we often print from our phones, tablets, and in our house, non-windows machines. Using an open-source program called CUPs. This can be done on almost any machine, but I chose to use my Ubuntu-powered PC. There are some variations if you use Windows.

This is a smaller project, and pretty easy.

Install and setup CUPs

To begin, download and install CUPs on your computer.

sudo apt-get install cups

Now it’s time to set up CUPs

Navigate to CUP server at 127.0.0.1:631 through a web browser.
Navigate to Administration Tab
Click “Add a Printer”
Select your printer.
Fill out the fields and enable “Share This Printer”. Click continue
Select your print driver (this could take a few attempts). In my case for the Brother HL2140, I chose Brother HL-2140 Foomatic/hl1250

Add to Google Cloud Print

Once it’s tested open up the Google Chrome browser (or Chromium) and perform the following:

  1. Navigate to chrome://devices/ in the Omnibar.
  2. Select “Classic printer”
  3. Add printers
  4. Manage printers
  5. Select the printer you want to add

Now that the printer is added, you can manage it at https://www.google.com/cloudprint/. Here you can share the printer with anyone with a Google account.

Takeaways and future thoughts

Unexpected problems:

Finding the correct Print Driver was a pain. I had to dive pretty deep into the Internet to figure out what to use, but I eventually found it!

Future Concerns:

Nothing. Just need to make sure that my PC is powered on at all times when I want to print.

Future Enhancements:

CUPs is currently installed on my PC. I may move it to a Raspberry Pi at some point. This will decrease the power required to run the print server (the Pi uses less juice than myPC), and it will allow the printer to become wireless, meaning it can be moved anywhere in my home.

Good morning, won’t you please take some time to save Net Neutrality?

What is Net Neutrality? From Battle for the Net:

“Net neutrality is the basic principle that protects our free speech on the Internet. “Title II” of the Communications Act is what provides the legal foundation for net neutrality and prevents Internet Service Providers like Comcast, Verizon, and AT&T from slowing down and blocking websites, or charging apps and sites extra fees to reach an audience (which they then pass along to consumers.)”

The Donald Trump appointed Chairman of the FCC, Ajit Pai, repeal it’s 2015 decision to reclassify broadband providers as common carriers under Title II of the Communications Act. This essentially provides ISPs (Internet Service Providers) with the ability to regulate how you use the Internet. Worst case scenarios include:

  • ISPs charging Netflix and Hulu more for people to access their sites
  • Comcast slowing all traffic to Netflix to promote their own streaming service

From NPR, “One key element at stake is the idea of paid prioritization, which would give Internet providers the ability to strike deals with content companies to give some apps and websites, or their own services, special treatment.

This is particularly a sensitive matter to Vimeo, a video service smaller than Google’s YouTube or other companies that offer video like Netflix, Amazon and now Facebook. Vimeo’s general counsel Michael Cheah says paid prioritization would “cable-ize the Internet” and hurt independent and small creators.”

If ISPs can speed up and slow down sites for money, and force small businesses with websites to pay extra fees, that’s a tax on everything. It costs all of us more, meaning we all pay more for less.

How can you help? Start by writing a letter to the FCC letting them know that you support a free and open Internet. The Electronic Frontier Foundation has created an incredibly simple tool to help you do that: https://dearfcc.org/ A more fun, but less user-friendly, the alternative is gofccyourself.com. This is a weblink that John Oliver made. Beyond that, contact your Senators and representatives in Congress.

Stand up for an open Internet, tell the FCC to protect Net Neutrality!

Mapping a Domain Name

I want to map my Domain name to my apartment’s IP address. There are a couple reasons for this. First, I think it would be fun, and it is the first step to hosting a website 100% at home, so I only rely on my ISP to provide an Internet connection.

DNS serves as the phone book of the internet.

Lets say I want to visit Mike. So, I pull out a phone book. I look up Mike, and learn he lives at 123 Main St. Now I can visit him!

DNS works in a similar fashion. I want to visit Google. I type Google.com into my web browser, and thanks to DNS, my browser knows to go to Google’s IP address! So, DNS connects a Domain to an IP Address.

Now, how can I send my domain, to my apartment’s IP address? BTW, this whole posts assumes you are using a Debian-based Linux system and that Google is your Domain Registrar.

  1. Buy a domain name
  2. Setup DNS settings
  3. Map to web server
  4. Setup Dynamic DNS
1. Buy a domain name

There are several registrars out there who you can purchase domains from. Godaddy is a large name in this industry, known for their ridiculous ads and poor treatment of women. I choose to go a more ethical route, and went with Google. This was easy enough, I started by going to domains.google.com for the domains I wanted. In this case, mikehelmers.com and helmershomestead.org. Each of these ran at $12 a pop. But you can get nearly any domain that’s available. I entered my credit card info, bought my domains. Easy.

2. Setup DNS settings

Now that I had my domains, I had to point them at my websites. Since WordPress is hosting mikehelmers.com, I need to set up that domain to use WordPress DNS servers. WordPress provided their server names, and most companies make it pretty easy. For helmershomestead.org, I kept it on the default Google provided DNS servers.

3. Map to web server

For the WordPress hosted mikehelmers.com, I’m done. They’ll take care of everything else. But for the soon to be self-hosted helmershomestead.org, there’s still quite a bit more. Under the ‘Registered Hosts’ part of the DNS Settings page, I added my IP address. I did this for both www.helmershomestead.org and helmershomestead.org because people might enter both URLs.

I also updated the Customer Resource records, the ‘A’ records, the ‘TXT’ record, and the ‘CNAME’ record. The A Record is the primary method that a Domain maps to an IP address. The TXT Record is added because I have my sites connected to Keybase to verify that I own them. I’ll write about Keybase at a later time. CNAME further helps with mapping subdomains (www) to the primary domain.

4. Setup Dynamic DNS (Optional for most people)

One of the issues with mapping a domain name to your homes IP address is that it is not static, meaning that it can spontaneously change. Now, is that likely? No. But it can happen, and at some point, will happen. ISP’s are loathe to give someone like me a static IP address and, generally speaking, home servers are frowned upon. But whatever, they’re shady companies. To get around this issue I am going to use Dynamic DNS(DynDNS). This technology uses software to automatically check what a devices IP Address is, and then tell the DNS server what the IP address is. At domains.google.com go to the DNS settings for your domain name. Go to the ‘Synthetic Records’ section of the page and select ‘Dynamic DNS’ from the dropdown menu. This will generate the username and password that you will use after installing DDClient.

Next, install DDclient from the command line:

sudo apt-get install ddclient

You will be asked some questions, fill them out the best you can, but it doesn’t really matter. Once installation is complete open up the ‘ddclient.conf’ file:

sudo nano /etc/ddclient.conf

Overwrite the existing text with the following lines:

protocol=dyndns2
use=web
server=domains.google.com
ssl=yes
login=Google_generated_username
password=Google_generated_password
whateveryourdomainis.com

Save and close the document and run the following command:

sudo ddclient -verbose -foreground

This will let you know if ddclient has successfully updated Google’s DNS servers with your external IP address.

There we go. now when I go to mikehelmers.com, is hosted by WordPress.com and helmershomestead.org independently in my apartment. Now if my public IP address changes for any reason, DDClient will check and update Google’s DNS servers accordingly.

Takeaways and future thoughts

Unexpected problems:

There was some hiccups with setting up the Dynamic DNS service, but it was because I mistyped some words.

Future Concerns:

Nothing

Future Enhancements:

Nothing at this time. This porject does exactly what I expected it to do.

I received a much help from the authors of the following sites:

 

ownCloud Down!!!

The other day I was updating the Raspberry Pi, and some updates got pushed out to the Pi running ownCloud. And it broke… Apparently, ownCloud itself was updated, but the update pushed the application into Maintenance Mode. I had to fix it. 

Went to /var/www/owncloud/config/config.php and changed ‘maintenance’ ==> true, to  ‘maintenance’ ==> false, and then returned to the ownCloud login page. Fortunately for me, from there it was easy. ownCloud asked if I wanted to install the update, and I said yes. Next thing you know, I was up and running.

That’s one of the cool things about these projects, new issues keep coming up. It’s good to always have an opportunity to try something new practice my troubleshooting skills.

What does my dog do all day?

My wife Kristin and I were talking about our dog, Wendy. We were wondering, what does she do all day while we’re at work?

Wendysaurus Rex
Wendy likes to stand on her hind legs.

This inspired the WendyCam. Our little pup is insanely curious, and always trying to get people food. In fact, we only recently learned that she can leap onto our kitchen table! But does she do this when we’re gone? Using a Raspberry Pi and some extra hardware, I built an always-on webcam to stream and take pictures when motion is detected.

One of the really cool things about this project was how much I learned about Linux as an OS. I learned more about how permissions work, and this was a great exercise in using Bash, as I did this entire project by logging in through SSH.

For this project I used the following:

– Raspberry Pi Zero
– USB wireless network adapter
– Raspberry Pi Camera module (You could also use a PS3 Eye Camera or any other USB camera)

Steps I followed:

  1. Prep Raspberry Pi Zero
  2. Install Motion
  3. Configure Motion
  4. Watch dog and be happy
1. Prep Raspberry Pi Zero
Wendicam on Raspberry Pi Zero
Wendycam on Raspberry Pi Zero

I choose the Pi Zero because of its small size. I want the computer to be fast so I loaded it with Raspbian Jessie Lite. This image of Raspbian does not come with a GUI, so you have to access it totally through the command line. Once the Pi was setup correctly, I connected my Pi Camera module camera. I went with this camera because of its small form factor. To use it, I had to go into the Raspberry Pi’s configuration to activate the camera. I could use almost any other USB camera. Additionally, I have tested it out with an old PS3 Eye camera I had lying around with no issues. I then plugged in a USB WiFi adapter so that the WendyCam can connect to the internet.

IMG_20170605_213310After getting Raspibian ready to go I created a case. It’s pretty fancy. I used electrical tape and a lunchmeat container.

 

 

2. Install Motion

Why Motion? Well, Motion is an open-source software that is pretty simple. It does not take many resources to run, and there is a ton of documentation out there.

sudo apt-get install motion

That installs the program. Next, I opened up a file that would allow the daemon to run on startup.

3. Configure Motion

Save the changes and open up the /etc/default/motion file and make the following changes:

sudo nano /etc/default/motion

start_motion_daemon=yes

Next, I opened up the program’s configuration file. This is what really controls the software. Starting out I edited a few things to get a higher resolution and allow streaming.

sudo nano /etc/motion/motion.conf
# Image width (pixels). Valid range: Camera dependent, default: 352
width 1920
# Image height (pixels). Valid range: Camera dependent, default: 288
height 1280

# Restrict stream connections to localhost only (default: on)
stream_localhost off

FOR PICTURES:
# Threshold for number of changed pixels in an image that
# triggers motion detection (default: 1500)
threshold 3000

# Picture frames must contain motion at least the specified number of frames
# in a row before they are detected as true motion. At the default of 1, all
# motion is detected. Valid range: 1 to thousands, recommended 1-5
minimum_motion_frames 4

# Target base directory for pictures and films
# Recommended to use absolute path. (Default: current working directory)
target_dir /var/lib/motion

After this, I forwarded port 8081 from the internet to the Wendy Pi’s internal IP address. This allows me to view the WendyCam from my phone.

4. Watch dog and be happy

To start I type:

sudo motion

And there we go! Kristin and I can watch Wendy all day long! Turns out she mostly sleeps. But, she looks adorable doing it.

Screenshot_20170526-115904

Takeaways and future thoughts

Unexpected problems:
The settings within Motion are all over the place. It took a bit of time to optimize it for the Raspberry Pi camera module. The default settings also took a ton of pictures. At least 1GB a day. Tweaking the settings slowed this down.

I also learned that I couldn’t easily delete the photos in the /var/lib/motion folder. Although this was eventually solved by changing the app permissions

sudo chown pi /var/lib/motion
sudo chmod 777 /var/lib/motion

I also stopped it from taking pictures all together so we only use it to stream now.

Future Concerns:
As always, what happens if my IP address changes?

Future Enhancements:
I need a camera case! It’s great that I have the camera up and running, but I want to protect the camera cable, and maybe mount the Wendycam on the wall.

I received a much help from the authors of the following sites:

http://www.techradar.com/how-to/computing/how-to-build-a-raspberry-pi-security-camera-1321441

https://github.com/Motion-Project

Google Phishing PSA

There was a phishing email going through Gmail earlier today, and Google​ pretty much solved the problem, but… Here’s some thoughts.

Don’t open it. It is from hhhhhhhhhhhhhhhh@mailinator.com, and looks like someone is sharing a document with you. They’re not. 

Delete it.

If you already opened it, change your password ASAP.

Also go here: https://myaccount.google.com/permissions and remove permissions for “Google Docs” if it appears there. This is a really well-done phishing attack.

Mike defines tech

Hey, there! I’ve got a brief update. I’ve added a “Tech Terms” page the website. As I write these articles, I find that I’m constantly defining some terms that I use. Now, this blog is for beginners and tinkerers alike, so I want to cater to everyone. Going forward, if you are wondering what I’m talking about, click on over to the Tech Terms page and learn something new.

In the coming weeks, I have several articles in the works, and I can’t wait to share my new projects with you!

I Built a PC!!!

This is a project I wanted to do for a long time. When I started studying for my CompTIA A+ cert, I was shocked at how much I learned about the hardware side of computing. My current laptop, a great Sony Vaio, was bought in 2009 after my college laptops motherboard finally croaked. Freshly loaded with the new Windows 7 OS, my Vaio served me faithfully until a month ago when the errors started to pile up. In an effort to health the machine, I attempted to load Ubuntu onto it. Ubuntu is a Debian-based Linux operating system that requires fewer resources than Windows to run. But alas, the strain was too much for the Vaio, and it is no more.

But now what? At home, we have a Chromebook and a laptop that kind-of-works. But I want something with a little more power. Something that I can upgrade over time. Computing constantly changes, and it would be able to improve my machine over time. Spend $200 every few years instead of $700+. Plus, building would be a fun project.

Where do I start?
1. Defining my needs: To know what to build, I need to know why I’m building it.
2. Choosing and buying the parts: I need to buy each individual part of my machine. So I need to decide what will meet my needs, and where to purchase it.
3. Assemble the computer: I need to put the parts together, duh!
4. Install the OS: To use the computer I need to install Windows or a Linux system.
5. Configure PC for use: Setting up the PC to my preferences.

1. Defining my needs:

What do I plan on using this computer for? Coding, generic Raspberry Pi support, picture/video editing, and some gaming. For my purposes, picture/video editing will probably require the most power, due to the size of the files. But, I’m not a professional, and nor do I play games that are new so I can make some sacrifices there for power.

2. Choosing and buying the parts:

To assemble my plan, I went to PC Part Picker pcpartpicker.com. You can view my parts list here: https://pcpartpicker.com/list/jbPZD8. This list is actually modified from a build featured at Lifehacker. I’ll go down this list talk about each component, and why I chose it.

  1. Intel Core i3 6100 3.7GHz Dual-Core: The processor is the heart of a computer. It’s what controls how the computer functions. Much of what I read suggested that I go for an i5 quad-core processor, which is a newer and more updated processor from Intel. As stated above, I don’t think I need that power. the i3 should work fine for me. If it turns out it isn’t enough, I can always replace it, or by a video card at a later date. In the near-term, going with the i3 saves me $100-$150.
  2. MSI H110M Gaming MicroATX LGA1151 Motherboard: While there are a million options when picking a motherboard, I feel a few questions really narrows it down. First, are you using an AMD or Intel Processor? These two companies use different designs, which limits the type of board you can use. Next, what form factor do you want? I wanted a MicroATX, as this is the current standard. And finally, what type of interfaces do you want? VGA, HDMI, USB 2.0, USB 3.0, USB C, and audio connections are all items to take into consideration. The MSI board suggested by LifeHacker ticked off everything I wanted, so I decided to go with it.
  3. Corsair Vengeance LPX 8GB (1 x 8GB) DDR4-2400 MemoryRAM (Random Access Memory) is the memory that used by PCs to run programs. RAM generally comes into play when running programs, so I want to have enough. Modern 64-bit operating systems have an upper limit over 17 million GB of memory, but I don’t need that much. Yet. 8GB is plenty, and should I need more, there’s an extra slot to place another stick of RAM in the future.
  4. Kingston SSDNow UV400 120GB 2.5″ Solid State DriveSSD’s (Solid-state Drive) are the future. Probably. They are starting to replace traditional hard drives. They are less prone to data loss from being moved around, and the memory in the SSD can actually be used in place of RAM in some cases. The other advantage is a faster read/write capability. Programs loaded onto the SSD will load faster than ones loaded on a traditional HDD. This is where my Operating System will be loaded.
  5. Seagate BarraCuda 1TB 3.5″ 7200RPM Internal Hard Drive: Here is the traditional hard drive (HDD- Hard disk drive). Any media I have (pictures, movies, music) will be stored here. Why bother having this when I have an SSD? Byte for byte, a traditional HDD is significantly cheaper. That’s why this 1TB HDD drive is less than a 120GB SDD.
  6. Cooler Master N200 MicroATX Mini Tower Case: I went with the suggest tower here. This is the case that will hold all of the components described above. This one has plenty of space inside and two fans to ensure adequate airflow through the computer. That’s important because computers can get hot. Sometimes they get so hot, parts melt. Then it gets really expensive.
  7. EVGA 500W 80+ Bronze Certified ATX Power Supply: Again, I went with the suggested PSU (Power Supply Unit). 500W is more than enough power, with plenty to spare, and allows me to expand in the future.

Once I made this list I went to Amazon and purchased them. With PC Part Picker, you can actually track the prices of different components over time from several different sites. I found that Amazon tended to have the cheapest price at any given time. On the odd chance that they were more expensive, it was only by $1-$4.

Now it’s time to Build!!!

3. Assemble the computer

This whole process went much smoother than I anticipated. I followed several online instruction lists, watched a couple YouTube videos, but at the end of the day, the paperwork that came with the components was the most useful tool I could have asked for. So I grabbed my trusty screwdriver and got to work.

I started with assembling the motherboard first. I place the processor in its slot and followed that up with placing the cooling fan on top. This fan will pull heat off the processor, stopping it from, well, overheating.

Next, I plugged in my stick of RAM. Too easy.

Following that, I installed the PSU into the bottom of the case, and then connected the motherboard to the side of the case.

I followed up with installing the SSD and HDD.

The last step was plugging everything in. This took quite awhile, but fortunately, nearly every connection has a unique shape, and most cables were labeled.

I plugged in the PSU, pressed the power button, and voila! I got the BIOS!!!

4. Install the OS

I decided to use Ubuntu as the OS for my PC. I wanted to save $120 by not using Windows, and I wanted a traditional desktop feel. Ubuntu is great. It’s easy to use, it’s stable, and there is a huge community of support. Plus, it’s built on the Debian branch of Linux, which I’m familiar with thanks to my time using Raspbian.

I downloaded the image off of the Ubuntu website. I used an arcane Windows program called Win32DiskImager to flash the image to a USB Drive. The Raspberry Pi Foundation suggests using a program called Etcher. After installing Ubuntu, I will learn I don’t need extra programs, the OS has an amazing formatting tool and writer built in!

Once the flash drive was created, I booted up the computer and received instructions to try Ubuntu, or install it. I chose to install it. I followed the instructions, and I was ready to go quickly.

As an aside, most modern computers will boot an OS and run it from a flash drive. This is an excellent opportunity to try out different flavors of Linux, and see what you like the most.

5. Configure PC for use

Now that my computer has an OS, I can use it! I took some time to set up the display as I wanted, and download any additional programs that I want. Ubuntu comes with LibreOffice already installed, so I had an MS Office type suite installed. I also downloaded Chromium to use as a web browser. This list will grow as I move forward using this machine more and more, but until then, I’m psyched to play with my new toy.

Takeaways and future thoughts

Unexpected problems:
There was some difficulty loading Ubuntu. I was able to load it on my first boot, but then something broke during the install. Turns out my flash drive was bad. So grabbed a new drive, flashed a new image, and was good to go.

Future Concerns:
There is a small concern Ubuntu won’t work for me, and I’ll need to switch to Windows. But that’s a bridge I’ll cross when I need to. Otherwise, I can’t think of anything that I’m worried about right now.

Future Enhancements:
I may get a graphics card in the future, that could extend the life of the computer for little money. I’ll also probably add a webcam. Why not chat with people?

I received a much help from the authors of the following sites:

I made my ownCloud!

wp-1491187033641.jpgHave you heard the saying, “There Is No Cloud It’s Just Someone Else’s Computer”? And have you ever thought about what would happen if that person’s computer disappeared overnight? While the chances of Google or Dropbox disappearing are slim, these things do happen. After my wife and I got married, we started discussing how we’ll save all these digital photos from our wedding. We have them on a flash drive and on our Google Drive, but I wanted more control. It was time to build a Helmers Family Dropbox.

Why did I choose ownCloud? ownCloud is open source, to it is free and transparent. It has an app at the Google Play Store so I can backup photos from my phone. I happen to like the interface. Finally, there is a lot of community support and needed to rely on their help.

For this project, I used a full-sized Raspberry Pi 3. This model includes a built-in wifi card, 4 USB ports, HDMI port, and an ethernet jack. It also has a more powerful processor than the Raspberry Pi Zero, which is what I wanted. I also bought a 1TB Seagate External hard drive. This hard drive would be what our data would eventually be stored in.

Below I’ll go through the steps of building my ownCloud.

1. Raspberry Pi Prep
Basic instructions are located here

2. Build a Webserver
-I’m essentially building a website that I can store pictures on. To build and access a website, I need a server.

3. Add SSL to Webserver
-I don’t want people to be snooping and intercepting my data when I upload information, so I’m going to include a security certificate that created a secure message between my device (client) and ownCloud (server)

4. Install ownCloud
– ownCloud is an open source program that mimics Dropbox. I chose it because it has a mobile app for Android phones, and an easy to understand interface. There is also a ton of support on the web for any troubleshooting needs.

5. Prep and Mount hard drive
-The Raspberry Pi needs to know where to store my pictures, and the 16GB SD card is not enough space. I must point ownCloud towards the external hard drive.

6. Configure access to my phone, the internet, and sync data
-Time to make the device usable. Here I’ll get the program up and running, and then sync it to my phone and start copying files over.

1. Raspberry Pi Prep:

The easiest part. I used Jessie Lite with no GUI in order to save some space on the Pi and decrease its need for processing power. Once the Pi was setup, I ran apt-get update, to ensure all the package lists were current.

I also setup a static IP address for the Raspberry Pi on my local network. I went into my routers settings and used the DHCP Reservations feature. In this case, it was 192.168.1.143

2. Build a Webserver:

The web server was the second easiest part. I ran the following commands:

sudo apt-get install apache2
sudo apt-get install php5 libapache2-mod-php5 -y
sudo service apache2 restart

This installed an Apache webserver and PHP (a programming language used on the web). This forms the foundation of how I will access my ownCloud. To test that the web server was setup correctly, I navigated to my Pi’s local IP address, 192.68.1.143. This brought up a default webpage.

3. Add SSL to Webserver:

This step is all about enabling HTTPS. Our friends at Sidewaysdictionary.com explain it the best: “It’s like living in a glass house. With HTTP, you have to bear in mind everything is unencrypted and theoretically open for others to see. That’s fine for some activities but gets awkward with others. With HTTPS, you can draw the curtains and close the shutters.” This ensures that regardless of where in the world I’m accessing ownCloud, no one else can see my data.

Here we go:
First, I needed to create a folder to store the security certificate.

sudo mkdir /etc/apache2/ssl

Then using openssl I generate a certificate and key.

sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -out /etc/apache2/ssl/server.crt -keyout /etc/apache2/ssl/server.key
nano /etc/apache2/sites-available/default-ssl.conf

After creating the key I replace the placeholder SSL Certificates (SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem and SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key) in /etc/apache2/sites-available/default-ssl.conf with the keys I just created (SSLCertificateFile /etc/apache2/ssl/server.crt and
SSLCertificateKeyFile /etc/apache2/ssl/server.key).

Then I activate the encryption.

sudo a2enmod ssl

And restarted Apache

sudo service apache2 reload

Boom, I have a HTTPS site!

4. Install ownCloud

I followed the instructions found on the ownCloud website:

sudo wget -nv https://download.owncloud.org/download/repositories/stable/Debian_8.0/Release.key -O Release.key
sudo apt-key add - < Release.key
sudo sh -c "echo 'deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /' > /etc/apt/sources.list.d/owncloud.list"
sudo apt-get install owncloud

After ownCloud installed, I had to redirect the default Apache webpage to ownCloud. I completed this by editing lines within the “000-default.conf ” file. I entered:

sudo nano /etc/apache2/sites-enabled/000-default.conf

Within the 000-default.conf file, I changed the DocumentRoot to /var/www/owncloud. This redirects any port 80 (HTTP) traffic on the Raspberry Pi from the Apache Default page to the ownCloud Default page.

Expand ownCloud ability to upload:
Now, I want to make sure ownCloud can upload any files I want it to. I edited the settings in a couple of files. ownCloud can upload files up to 2GB. These edits will allow me to do that.

sudo nano /var/www/owncloud/.htaccess
hp_value_upload_max_filesize 2000M
php_value_post_max_size 2000M
php_value_memory_limit 2000M

sudo nano /var/www/owncloud/.user.ini
upload_max_filesize=2000M
post_max_size=2000M
memory_limit=2000M
5. Prep and Mount hard drive

This will allow ownCloud to store data

on my 1TB external drive. Why? The 16GB SD card within the Raspberry Pi is nowhere near large enough to store all of the files I want.

wp-1490186169806.jpg

I need to format the drive to NTFS. This is a format that Windows can read, so down the road I can view the contents of the drive on a Windows computer if needed. I need to install a formatting program and then format the drive.

sudo apt-get install ntfs-3g

Then I formatted the drive to NTFS

sudo mkfs.ntfs /dev/sda1 -f -v -I -L untitled

Next, I made a directory to mount the drive to, a permanent location ownCloud will always know to look.

sudo mkdir /media/ownclouddrive

Now I needed the UUID. This is a unique identifier on my external drive. After updating some files, anytime the Raspberry Pi detects this UUID, it will connect it to the /media/ownclouddrive directory that we just made.

Detect the UUID with

sudo blkid

Open the fstab file

sudo nano /etc/fstab

Paste the following: UUID=”UUID from blkid” /media/ownclouddrive auto nofail,uid=33,gid=33,umask=0027,dmask=0027,noatime 0 0

6. Configure access to my phone, the internet, and sync data

Initial Setup: Now that ownCloud is up and running, it’s time to set it up! Through a web browser, navigate to the Pi’s local IP address. https://192.168.1.143 or https://192.168.1.143/owncloud. I received a certificate error message, but that is OK. I just clicked on it. That error shows up because your browser sees the certificate, but does not recognize it as trusted. But I built it, so I trust it.

The first action ownCloud will have you take is to create an admin account. Do that. Then select the storage & database option. Through that link, direct ownCloud to /media/ownclouddrive. This tells ownCloud to store data on your external hard drive.

Enable access from the outside world. I forwarded TCP port 443 (HTTPS) on my router to my Pi. This means that if I enter my external IP address and point it toward port 443 (XXX.XXX.XXX.XXX:443), I can access ownCloud from anywhere on Earth.

Download the app from your preferred app store, Google or IOS. After installing the app, it was straightforward to set it up.

You can also download desktop clients, but I have not played around with that yet.

Take some time to dive into the literature at owncloud.org, as there is a ton of settings to tweak. You can even run your own email server or version of Google docs!

That’s it. Enjoy your “own” ownCloud!

Takeaways and future thoughts:

Unexpected problems:
I made so many mistakes. I constantly edited wrong files, mistyped commands… I eventually just wanted to start from scratch but wanted to overwrite what I have already edited. It took awhile, but I finally found the command to do that with:

sudo -o Dpkg::Options::="--force-overwrite" apt-get install apache2

Future Concerns:
As always, what happens if my IP address changes? I need to find a permanent solution. I am also curious to know if I can really read the data on the external drive from a Windows machine. This is tricky to test, as I don’t want to lose what I’ve already stored.

Future Enhancements:
I want to sync my already existing Google Drive and Photos with my new cloud. I will have to look into that in the future.

I received a much help from the authors of the following sites:

https://pimylifeup.com/raspberry-pi-owncloud/

http://projpi.com/diy-home-projects-with-a-raspberry-pi/pi-owncloud-drop-box-clone/