When the was first released, I was one of the first journalist in the country to receive one, and impressed did not begin to describe how I felt about the little black board. At the time, I was still riding a high from my experiences with the Raspberry Pi, and while the Black lacked the camera and LCD connectors, it made up for it in on-board flash and processing power. Unfortunately I was very disappointed in the Angstrom Linux distro that shipped with the Black, but did manage to flash the board to Ubuntu with the help of a friend at my local MakerSpace. Over the next several months, I played with the Black here and there, and made a few small projects here and there. When revision C of the BeagleBone Black came out running Debian from the factory, I knew I had to have one. It was also around this time that I made a major career change, and left tech journalism for a more lucrative position as a Drupal developer at a friends web development firm. While playing around with my new BeagleBone Black one night, I began wondering how hard it would be to get a web server up and running and if the Black would be able to handle MySQL and Apache2 along with a Drupal Install.
Prerequisites: What you need to know to be able to complete this project.
- Understand how to install packages from the terminal.
- Understand how a LAMP-based web server works.
- Understand how Drupal is installed and configured.
- Understand how RSS feeds work.
- Understand basic HTML and XHTML.
SSHing into the BeagleBone Black via Putty
To access the BeagleBone Black via SSH I will be using a terminal for Windows called putty, as well as an addon called MTPutty which allows me to run multiple putty instances from within a single tabbed interface. Both Putty and MTPutty are available for free, and take just a few moments to download and install. Chances are, if you are reading this, you already know how to use Putty. If you are using a Mac you can simply use the built-in terminal to access your Black Via SSH. To connect to your Black, you need to enter the following credentials.
With these settings configured, click ok and then double click the BeagleBone Black name in the server list. This will open up a new terminal tab and you will be prompted to enter a username. Unless you have modified the root user, you should enter root as the user name.
BeagleBone has made it easy here as there is no password and after entering the username, the connection will finish, and you will be placed in your "home" directory.
To get things started, I first needed to get MySQL installed and running on the BeagleBone Black, and I will be perfectly honest in saying that it was no easy task starting off. Since revision C of the Black runs Debian Wheezy from the factory, I knew that apt-get install would be used to install new packages now where as opkg was used with the Angstrom distro on earlier models. Unfortunately that is where I began running into problems. When I would run anything via apt-get install the whole install process would run, but then quickly error out due to a script called led_aging.sh causing an error. After almost an hour of pulling my hair out, and searching the web, I found a thread in a mail archive where someone was having the same problem. As it turns out the script was missing some of its functions, and that was causing the dkpg error, but why a seemingly random script was causing apt-get install to fail is beyond my pay-grade. If you are interested in seeing the original mail archive with the information, it can be found here. I am going to cover this fix below for convenience though.
If you get an error surrounding the led_aging.sh script when running apt-get install on your BeagleBone Black, or during any terminal process, you will need to modify that script to include some missing functions. The process to do this is found below, but you will need a basic understanding of the Linux file structure and how to modify files via the terminal to complete this. You can also check out this code on github.
- From your home directory navigate to /etc/init.d and then nano the led_aging.sh file that is inside the init.d directory.
- Replace all of the code inside the led_aging.sh file with the following code.
#!/bin/sh -e ### BEGIN INIT INFO # Provides: led_aging.sh # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start LED aging # Description: Starts LED aging (whatever that is) ### END INIT INFO x=$(/bin/ps -ef | /bin/grep "[l]ed_acc") if [ ! -n "$x" -a -x /usr/bin/led_acc ]; then /usr/bin/led_acc & fi
- Then exit out of nano, keeping the filename the same as it was.
This should have fixed the issue that pops up when trying to run an apt-get install command. Now that we have that error taken care of, lets move on to the rest of the project.
Installing and Configuring the Web Server
There are a few packages we need to install in order to get our web server up and running to be able to serve a Drupal installation. The packages we need to install are listed below.
- MySQL Server
- MySQL Client
Before we get started, we need to make sure that Debian is up to date with the latest libraries, and doing that is as simple as running the following command.
This will automatically download and install the latest update for the version of Debian that is running on the BeagleBone Black.
With the distro updated, we can now install MySQL Server and MySQL Client with a single command. For those of you following along at home, MySQL is the database of choice for Drupal installations, but you could run MariaDB, postgresql, or another variant of MySQL. To keep things simple and standardized, we will be running MySQL. To install both packages, use the command below.
apt-get install mysql-server mysql-client
This will run through the install process. You will be prompted with some password creation prompts and you can set the passwords to whatever you wish, but make sure to write them down as they will be needed later.
With MySQL installed, its time to install Apache2 run the following command
apt-get install apache2
Let the install process finish, and grab something to drink in the meantime.
With Apache2 installed, we can move on to building a Drupal-based website on the BeagleBone Black.
Installing and Configuring a Drupal-based Website
In the terminal, navigate to the srv/www directory, and create the directory in which we will install the Drupal instance too. We will need to create several sub-directories as well, including backup and error log directories as well as the website doc root.
cd /srv/www mkdir bbb.news cd /srv/www/bbb.news
Now create the sub directories using the commands located below
mkdir backup mkdir download mkdir logs mkdir htdocs
While only two of these directories are really needed, I prefer to follow what I consider to be best practice when installing drupal on any server. The backup directory is used to backup the website's database, making life much easier when things go bad. We will use the download directory to download the Drupal install tarball to. The logs directory will house two required error log files, and the htdocs directory will be where our website resides.
While we are at this level of the file structure, lets go ahead and create two files that apache will need later. Navigate to the logs directory and enter the two touch commands below.
cd logs touch access.log touch error.log
This creates the needed log files that will help troubleshoot issues if they occur.
With these files created we can navigate back to the main bbb.news directory and then into the download directory.
Once inside the download directory, we can use the wget feature to grab a fresh copy of the latest version of Drupal 7. While Drupal 8 is right around the corner, I chose to go with Drupal 7 because it is the most widely adopted version at the moment and has the most module support currently. Follow the commands below to download Drupal and untar it into the htdocs directory.
wget http://ftp.drupal.org/files/projects/drupal-7.32.tar.gz tar -zxvf drupal-7.32.tar.gz ../htdocs
Now verify that the files were successfully extracted to the htdocs directory by entering the following commands and matching up your directory with the screenshot below.
cd ../htdocs ls
Now we need to navigate to the sites/default directory and copy the default.settings.php file and rename it to settings.php, then set the permissions on the settings.php file to 777.
cd sites/default cp default.settings.php settings.php chmod 777 settings.php
To finish getting our Drupal site ready we need to build a database for it to store things in. You will need the MySQL username and password that you set up earlier in the tutorial for this. Use the following commands (with your unique credentials) to build the database we will use for the Drupal installation.
mysql -u (username) -p (password)
That should drop you into the MySQL terminal and from here you can create the database with the following commands.
create datab (database_name); grant all on (database_name).* to '(database_username)' identified by '(database_password)';
If everything was entered correctly, then you should see a line returned with the following command Query OK, 0 rows affected (0.00 sec) . Be sure to write down the database name, database user name, and database password as you will need them shortly. If things are correct, you can now exit the MySQL terminal using the following command.
Now lets set up the vhost file for our newly installed website. Navigate to the apache2/sites-available directory using the following command.
Now we need to create a new virtual host file (vhost) for our newly installed drupal website. To do this, we are simply going to use the touch command to create the file. If you want to be able to access the website you are building from an external network, you will need to configure a new A-record on a domain name that you own, and point it to your home's IP address, then forward the ports in your router to the BBB for that domain name. I wont cover those aspects in this tutorial, but the internet is full of valuable resources that will help you along the way. For the purpose of this tutorial, I have already completed these steps, and that is why you see the charlesjgantt.com domain attached to the vhost. When doing this on your own, simply replace my domain name with yours. I will post some screen shots of what my setup looks like, to help you along though.
Now run an ls command to verify that the file was created.
If the file was created correctly, you should see it here.
Now we need to edit the file and paste in a few lines of text. Nano into the bbb.news.(your_domain.com) and paste the following text. Remember to remove the (your_domain) and replace it with your domain url.
CustomLog /srv/www/bbb.news/logs/access.log combined
Now save and exit out of nano by pressing ctrl+x and y when prompted then saving with the same name.
You have successfully created a proper Virtual Host file for the new Drupal site. Now we need to enable that site using the following command. Once enabled, apache will need to be restarted.
a2ensite bbb.news.(your_domain).com service apache2 reload
Below are the screenshots I promised of my A-Record entry in my DNS settings for charlesjgantt.com as well as the port forwarding settings in my router.
Your A-Record can be found in the DNS settings of your domain. Simply give it the sub-domain name you wish to use, and then point it towards your home IP address. (Mine has been blurred out for security purposes.)
Now enter your router's settings and find the port forwarding settings. You want to point the port you set in the V-Host file (80) to port 80 on your router. After saving this, you may need to reboot your router depending on its model.
In preparation for the BB View_70 LCD we will cover later in this tutorial, we need to disable a few services on the BBB to ensure that port 80 is free to serve our new website.
systemctl disable bonescript.service systemctl disable bonescript.socket systemctl disable bonescript-autorun.service systemctl disable avahi-daemon.service systemctl disable cloud9.service systemctl disable gateone.service
With these items finished, we are ready to test the website and see if it works. From within your local network, open up a browser such as Chrome and visit http://bbb.news.(your_domain).com:80 and if everything is correct, you should be prompted with the drupal install page as seen below. You will have to select your preferred language, and then if the steps above were followed, you will be taken to the Database configuration tab. Select MySQL, and then enter the correct Database Name, Database Username, and Database Password that you set up a few minutes ago.
Now click save and continue, and proceed to fill out the requested information on the final few pages. When finished you should be prompted to visit your new website which should look something like this!
Now that we have the news website up and running on the BeagleBone Black, we need to begin importing "News" content to it. Before we can do that, we need to install a few modules and to make life easier, we are going to install a utility called Drush (Drupal Shell) that will make life much easier moving forward. While seasoned Drupal Developers will certainly cringe at the method I am about to use to install Drush, it will work fine for this tutorial. To install Drush using the preferred method, visit the install instructions found at https://github.com/drush-ops/drush
apt-get install drush
Before we can install any modules we need to modify the permissions on the modules directory, and then create two new directories.
chmod -R 777 sites/all/modules cd sites/all/modules mkdir contrib mkdir features
When the Drush install finishes, navigate to the websites root, and then use the drush pm-install and pm-enable commands to install the needed modules. The final command we will run in this set will clear all of Drupal's various caches.
cd /srv/www/bbb.news/htdocs drush dl admin_menu adminimal_admin_menu module_filter features feeds feeds_tamper feeds_imagegrabber job_scheduler strongarm context drush en admin_menu adminimal_admin_menu module_filter features feeds feeds_tamper feeds_imagegrabber job_scheduler strongarm context -ydrush cc all
With those modules installed and enabled, hard-refresh the webpage and then visit the modules page to verify that everything we needed was properly enabled. Go through the list and make sure that Context, Context UI Features, Feeds Admin UI, Feeds Import, Feeds News Feeds Tamper Admin UI, Feeds Tamper, Feeds, Feeds Image Grabber, Job Scheduler, Job Scheduler Trigger, and Strongarm are enabled.
With all the necessary modules enabled, we can move forward and build a feed importer that will allow us to pull in news from any website with an RSS feed. For the purpose of this tutorial, I am going to pull new content from Element14's All Content RSS Feed which can be found at http://www.element14.com/community/groups/feeds/allcontent. I am also going to pull in a feed of the newest 3D models uploaded to httphttp://www.thingiverse.com. To keep all of this organized, I need to create a new content type for the Thingiverse feed. Before I decided what I would be importing, I named this new content type "Tech News" but its sole purpose is to import from Thingiverse, so ignore the name and make yours whatever you want.
To get started creating the new content type and feed, follow along with the videos below.
I apologize for not being able to show the Thingiverse Feed creation. At the time of recording, the Thingiverse RSS feed had a bug that prevented me from mapping the elements correctly, but basically it is the same as creating the previous feed, but involves using Feeds Tamper, and Feeds Image Importer to get the images displaying correctly. A quick good search will show you the best way to utilize these extension modules.
Now that we have the feeds importing, and the site is up and running as it should, lets take a moment and look at how we can add the to create a desktop rss news reader. For those of you who are new to the BeagleBone Black, the BB View_70 is a 7-inch 18-bit, 800x480 resolution LCD screen with a 4-wire resistive touchscreen digitizer on top. The Cape features two user-defined LEDs, and five tactile switches of which 4 can be user defined.
Originally, the BB View_70 ran on the Angstrom distro, but with Debian being added as the default OS in revision C of the BeagleBone Black, the BB View_70 cape is easier than ever to get up and running. I could cover that entire process here, but it is actually very thoroughly covered in the BB View User Manual beginning at page 23. Note that if you run the BB View_70, you will need to supply an external 5V 1amp power source to the BeagleBone Black before the screen will turn on.
For those of you with access to a 3D Printer, you can head over to Thingiverse and download the BBVIEW 7 LCD + Beaglebone Black Stand by Chumsize. This stand provides a clean way to securely and safely mate the BeagleBone Black and the BB View_70 together. The stand holds the screen at the perfect angle for both viewing and touch screen navigation. The stand takes about 35 minutes to print on a decent printer running at about 80mm/sec and uses hardly any ABS filament. I did find that the holes designed to capture the standoffs need a bit of cleaning, and you will need to heat the standoffs with a cigarette lighter or soldering iron and then press them into the holes for a more secure fit. Overall I think this stand is one of the coolest things I have ever printed, and it has made my development time with the BB View_70 much easier.
I'm a screen junky and at my home office, I have tripple 24" monitors, with about 30 tabs open in each at any given time. I know this is excessive, but having this little news reader on my desk really does make life easier. As an additional bonus, since it only imports the latest 10-items every hour, I spend less time down a news rabbit hole, and more time working. I hope this tutorial was as informative as I hoped it would be, and I would love to hear from anyone who makes their own news reader, or takes these instructions and builds something completely different. I have a few more tutorials coming out in the next couple of weeks that will build upon this basic starter, such as learning how to control the BeagleBone Black's GPIO pins via the internet using Drupal. Until then #HackTheWorld & #MakeAwesome!