How To Set Up a Recipe Server

Today Gary asked…

Would you mind doing a walk-through on how to setup a file server, perhaps alongside my existing media server (movies and music) from a fairly new Linux user perspective.

Will different types of servers coexist without problems? I would like to setup a file server for recipes so that my wife could access them on a tablet that is mounted in the kitchen. How would you setup a menu that would allow her to quickly access a recipe when there are perhaps hundreds on the server? Would I also need a database of some kind to do this efficiently or is there a simpler way of getting this done? Will I need an app on the tablet (Android OS) to access the server?

Thanks

Gary


Hi Gary,

The attached video will answer your questions while this article will help you get your server set up.

Before getting started: Some things to remember: One, I’m assuming you’ll have local access to the server in question. Thus, not needing SSH, etc. Two, Plex, ownCloud and WordPress all work great on a tablet. Just enter the IP address or better yet, set up static IP addresses on your router. Bookmark them and you’re golden.

Step #1 – What are you going to run your media/recipe server on – an old PC tower? As I talked about in the video, you could potentially run the entire thing on something as light on resources as a **Raspberry Pi. A better alternative might be an old desktop or laptop you’re not using. In the end, I’m a big fan of using what’s available vs needlessly spending money on yet another computer. If you have money to burn, you could even buy a NAS…but it sounds like you’re willing to use what’s already available. For the video, I used Ubuntu Server 14.04 for the Raspberry Pi 2.

Step #2 – Pick a media server. Based on what you’re describing, Plex might be the best bet. Now after following the linked guide for its installation, here are some additional things that will make setting up Plex much easier on a PC such as a laptop or a tower. I realize you have an existing media server. So if you’re happy with it, great. But Plex is a great option if you’re not already using it.

**Note: Freedom Penguin’s own editor, Eric Beyer has informed me that his “Plex-on-Pi” experiences have been less than stellar. Annoying to install, performance issues, etc. So while it can run on a Pi, it’s probably not the best solution overall. So while you can run a media server on a Pi, you might want to consider an actual PC if you plan on enjoying your media successfully.

To get Plex running successfully, enter the following commands for as to avoid common user/group/permission headaches. This assumes Ubuntu LTS is being used as your distro of choice. If you’re running something with systemd instead, this applies. For a media/recipe server, I highly recommend sticking with Ubuntu 14.04 LTS.

Create a Plex group:

sudo groupadd plex

Add yourself and Plex to the new group:

sudo addgroup YOUR-USER plex

 Change group:

sudo chgrp -R nogroup /var/lib/plexmediaserver/

Change ownership:

sudo chown -R plex /var/lib/plexmediaserver/

Use restart as it may already be running:

sudo service plexmediaserver restart

Finally, ensure that you’re firewall ports are allowing Plex to do what it needs to do.

Step #3 – Once you have Plex, or whatever media server you’ve decided to use , you’re ready to install ownCloud. This will allow you to import and manage your EXISTING recipes. I believe ownCloud is a great choice because it’s fantastic for tablet usage, plus it doesn’t require an app…although one is available if need be. Everything from here forward assumes that Ubuntu 14.04 LTS is being used.

sudo apt-get update && sudo apt-get upgrade -y

We’re going to use MariaDB over MySQL as I’ve found it performs better:

sudo apt-get install mariadb-server
sudo apt-get install apache2 php5 php5-mysql

the above apt install should cover the following automatically…but just in case:

sudo apt-get install php5-gd php5-json php5-curl php5-intl php5-mcrypt php5-imagick

Some or all of the items above may already be installed. Perhaps you’re running a LAMP stack already, negating the efforts above. If you have MySQL installed already, that’s fine, the interaction for database creation, etc, with both MariaDB and MySQL are similar. In short, don’t worry about it, the next steps worth with both options. When you install either MariaDB or MySQL, you will have been prompted to create a root password. Remember it, you’ll need it.

Let’s create a new database and user for your upcoming ownCloud installation. You can choose the database name and user. But for the sake of simplicity, I’m using ownclouduser and ownclouddb so you can spot the differences. Also, the items below are in some instances case sensitive – so just assume everything below is to be safe.

sudo mysql -u root -p
CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'yourpassword';
CREATE DATABASE ownclouddb;
GRANT ALL ON ownclouddb.* TO 'ownclouduser'@'localhost';
FLUSH PRIVILEGES;
exit

Now it’s time to install ownCloud. Gary, usually I’d suggest getting the latest version from ownCloud directly. However for the sake of keeping things simple, we’ll simply use a reliable repo. After digging a bit, the best approach turned out to be as follows.

cd /tmp
wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.04/Release.key
sudo apt-key add - < Release.key

Now we’re ready to add the repository to your sources.

sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/owncloud.list"

And finally, let’s install ownCloud itself.

sudo apt-get update
sudo apt-get install owncloud

To be on the safe side, restart the apache server.

sudo a2enmod rewrite
sudo service apache2 restart

This is a good time to make sure your ownCloud instance is configured.

cat /etc/apache2/conf-enabled/owncloud.conf

Running this command should present you with something like this.

Alias /owncloud "/var/www/owncloud/"
<Directory "/var/www/owncloud">
Options +FollowSymLinks
AllowOverride All
</Directory>

I’ve found that since I’m running WordPress as well, that it’s best to configure it as follows using nano/vim/whatever. Unless you’re familiar with it, I recommend nano for most people.

sudo nano /etc/apache2/conf-enabled/owncloud.conf

Change the contents to look like this.

Alias /owncloud "/var/www/owncloud/"
<Directory "/var/www/owncloud">
Options +FollowSymLinks
AllowOverride All
SetEnv HOME /var/www/owncloud
SetEnv HTTP_HOME /var/www/owncloud
</Directory>

 Full disclosure: I’m not an Apache expert nor do I claim to be. I simply now how to get things done and do so with the outcome I’m looking for. So feel free to try using the above environment variables or not. For myself, I’ve found that the latter configuration with the environment variables meets my expectations perfectly.

Whatever changes you make to owncloud.conf, be sure to refresh everything after every change.

sudo a2enmod rewrite
sudo service apache2 restart

Step #4 – Now that ownCloud has been installed, you can access it either locally on that machine via your Web browser…

http://localhost/owncloud

or by its LAN IP address.

http://YourLanIPaddressHere/owncloud

First, we need to create an administrator username and password. Anything is fine, but make sure you remember it. Next, look below the username and password boxes.You’re going to click on Storage & Database. You’ll notice that your data folder has already been selected for you. However, if it’s not, make sure it’s pointing to /var/www/owncloud/data or you going to have some issues.

Next, select the correct database option. In your case, this should be MySQL/MariaDB. Remember your database credentials you used earlier when building your new ownCloud database. Well, you’re going to need them for the boxes below.

Username: ownclouduser

Password: Whatever you chose for your database password earlier, NOT your administrator password

Database name: ownclouddb

Host: localhost

Congrats, you’ve just installed ownCloud to be used for recipe hosting, locally speaking.

Step #5 – Odds are better than fair that you’re going to want something a bit more “easy on the eyes” for your yetobe discovered recipes. As we discussed in the video, WordPress is a great option in this regard. So if you’re also wanting to install WordPress alongside ownCloud, here are the steps to take.

Now we already have MariaDB installed, along with all the other required prerequisites needed to run WordPress. Our next step is to begin by creating our database for WordPress.

mysql -u root -p
CREATE DATABASE wordpressrocks;
CREATE USER yourwordpressuser@localhost IDENTIFIED BY 'create a password';
GRANT ALL PRIVILEGES ON wordpressrocks.* TO yourwordpressuser@localhost;
FLUSH PRIVILEGES;
exit

With our WordPress database setup, the next step is to get a copy of WordPress. There are two ways of doing this. If you’re running the PC under a GUI, you could use your browser to download the package needed. Otherwise, use wget instead and extract the download afterward.

cd ~
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cd ~/wordpress
cp wp-config-sample.php wp-config.php
nano wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpressrocks');
/** MySQL database username */
define('DB_USER', 'yourwordpressuser');
/** MySQL database password */
define('DB_PASSWORD', 'created password from above');

After modifying the file, get ready to copy the files over to your web root. Now you could use cp to copy the files over. But I personally like using rsync for stuff like this.

sudo rsync -avP ~/wordpress/ /var/www/html/
cd /var/www/html

Check your work to make sure everything was copied over.

ls /var/www/html/wordpress/

This should present you with all the expected files and directories for your WordPress installation.

Because this wasn’t one of those smooth apt installations where the magic happens and all the ownership/permissions are setup for you, there are a few things left to configure before we begin the actual WordPress setup.

Start off by looking at the user that appears in your terminal. In my case, it’s matt – yours may not be a name at all. Whatever it is, this is considered the user that we’ll use to work with WordPress. Not in the login sense, rather from an ownership perspective. I’ll assume yours is called “user” for the basis of the remainder of this tutorial. Confused? Don’t sweat it, just follow along.

sudo chown -R user:www-data *

Now let’s make our upload directory.

mkdir /var/www/html/wordpress/wp-content/uploads

And then give it needed ownership information.

sudo chown -R :www-data /var/www/html/wordpress/wp-content/uploads

Don’t forget to set the permissions for your wp-content directory.

sudo chmod -R 755 /var/www/html/wordpress/wp-content

At this point, you should be able to browse over to the IP of your machine hosting WordPress and complete the installation. But this is an install built to be something LAN specific, not a WWW website. FTP isn’t really a great fit in my opinion for situations like this. Sure, you could install libssh2-php and move files back/forth via SSH. But if you want to simply want to upload files from the ~/ to /var/www/html/wordpress/wp-content, then clearly a direct file move would be preferred.

Using nano, simply open up the config file…

nano /var/www/html/wordpress/wp-config.php

and add the following at the very bottom of the file.

define('FS_METHOD','direct');

While you could have done this earlier, I intentionally left it out in case you wanted to use FTP or SSH to upload files.

Now, before we go any further, this a good time to complete our WordPress installation.

From a the local Web browser:

http://localhost/wordpress/

or if on another machine:

http://YourLanIPaddressHere/wordpress/

You’ll be asked to provide a site title (doesn’t matter what), username and password. Then an email address. Now, being this isn’t a public facing site, there is no advantage to checking the box for search engines to index the site.

Once all of this is done, simply click on Install WordPress, then login when prompted.

Step #6 – Setting up Apache Rewrite is going to make your life a lot easier. Doing stuff like setting up custom permalinks and other related activities depend on it. We already did this with our ownCloud install, now let’s give our WordPress install the same courtesy.

sudo nano /etc/apache2/sites-available/wordpress.conf
Alias /wordpress /var/www/html/wordpress
<Directory /var/www/html/wordpress/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/wordpress
SetEnv HTTP_HOME /var/www/html/wordpress
</Directory>

As above (see ownCloud examples), the environment variables are a matter of personal choice. I use them because I’ve found they seem to play nicely together.

Now let’s pop this into enabled status.

a2enmod rewrite
service apache2 restart

Now let’s create the needed .htaccess file that Apache expects.

touch /var/www/html/wordpress/.htaccess
chown :www-data /var/www/html/wordpress/.htaccess
chmod 664 /var/www/html/wordpress/.htaccess

By chmod’ing this to 664, you can change the permalink structure within WordPress without needing to enter it into the .htaccess file manually.

But Matt, what about Nginx or _____?

As I wrap this up, I wanted to touch on a few things. First, there are a hundred different ways to do this. Yes, I could have suggested that Gary uses Nginx instead. At a later date, I may even write up an article on setting up a Nginx WordPress installation. The process is very similar to that with Apache, with some minor differences under the hood with the config.

Personally, for casual projects like this does…it really doesn’t matter. The advantages between Nginx and Apache for a personal project are non-existent and merely a matter of preferred workflow (in my opinion). The only time one should care is when you’re working on a larger and/or public facing project.

Gary, while this was incredibly long, I hope it serves you well and you’re able to get your media/recipe server up and running. I realize this seems like a ton of information, but I’m sure if you follow this guide closely you can have that recipe server set up in no time.

Do you have Linux questions you’d like Matt to help with? Hit the link here and perhaps you too, can Just Ask Matt!

Also check out...

Matt Hartley
Founder at Freedom Penguin
Freedom Penguin’s founder & talking head – Matt has over a decade working with Linux desktops, his operating system experience consists of both Windows and Linux operating platforms. In addition to writing articles on Linux and open source technology for Datamation.com and OpenLogic.com/wazi, Matt also once served as a co-host for a popular Linux-centric podcast.

Matt has written about various software titles, such as Moodle, Joomla, WordPress, openCRX, Alfresco, Liferay and more. He also has additional Linux experience working with Debian based distributions, openSUSE, CentOS, and Arch Linux.

Leave a Reply and sign in below


Wordpress Register | Wordpress Login

Be the First to Comment!

Notify of

wpDiscuz