Home » Blog » Archives for Raspi

Author: Raspi

Raspi is our content writer. He loves to tinker with Raspberry Pi projects and learning about hardware and software development

indigo-magician

How To Use Rsync With A Raspberry Pi Web Server

I spent the better part of an evening figuring out how to make this work and thought I would share a video I created detailing how you can use rsync with your Raspberry Pi.

I am using rsync to move files from my laptop to my Raspberry Pi web server.

I had to string together 3 tutorials and will detail all my steps in this video below.

Here is the quick version

You will need to change the Raspberry Pi web server’s folder permissions to belong to the user who is rysncing the files.

You can change those permissions by issuing the following command

sudo chown -R youruser:www-data /var/www

You must do this if you are running Raspbian (Jessie) because Pi, the default user, is locked down from SSH which is what rsync uses. It is advisable to great a NEW user and not use Pi when doing SSH commands. If you need help creating a new user check out the video above.

Once the file permissions are changed you can rsync from your local setup to your Raspberry Pi web server with this command.

rsync -a ~/Projects/ExampleSite raspibakery@192.180.90.3:/var/www/html

I ran into issues with trailing slashes so leave them off.

You will be prompted for your new user’s password and if everything works you can now check http://localhost and see your changes.

amber-code

How To Install Nginx On A Raspberry Pi Running Jessie

I have installed a web server on my Raspberry Pi before. But when I went to do it this last time I noticed a few things have changed.

This post will walk you through some of the hiccups I had when following the official Raspberry Pi documentation on how to install Nginx on a raspberry pi running Jessie.

Here is the official documentation. I would suggest following along with these steps.

First things first, installing Nginx

It’s pretty straightforward to install Nginx on a Raspberry Pi…simply type in the following command,

sudo apt-get install nginx

The first hiccup I had was apt-get returned an error suggesting I update my package manager.

So I simply typed

sudo apt-get update

After a few minutes, I was able to execute the first command with no problems (you might not have to do this).

To start the Nginx server on your Raspberry Pi simply type

sudo /etc/init.d/nginx start

You can now test that your server is installed by visiting http://localhost/ in your browser.

If you want to just run static HTML files you can stop here.

However, if you want to install PHP which gives you the ability to run a scripting language and write more dynamic websites, you will need to install a few more things.

Installing PHP on a Raspberry Pi webserver

The command you are looking for is…

sudo apt-get install php5-fpm

Time to configure some settings

Navigate to cd /etc/nginx

In this file, I notice some discrepancies. I notice that what I had as a default looked very different then what the documentation we telling me.

I tried a few times to get it to work but kept getting the following error.

Reloading nginx configuration (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
 failed! 

Finally I just copied everything that was “suppose” to be uncommented in and reloaded the file and it worked.

So first things first.

We need to tell the server that we want the index file with the .php extension to take preference over those that are HTML.

Around line 25 you will need to add the index.php to the list so it looks like this

index index.php index.html index.htm;

Now, we need to uncomment some options. This is what I was talking about when I said it looked different. I just copied and replaced the section of options with what the documentation said I should have.

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
        }

This may not be a best practice but I was fed up with Googling error messages and looking in logs.

Finally we can reload this file

sudo /etc/init.d/nginx reload

Here is where things got fuzzy for me

The documentation tells us to change the index.html file to index.php to test if PHP files are being served correctly by the web server.

To do that we can navigate to the path below…

cd /usr/share/nginx/www/

And then change the file extension

sudo mv index.html index.php

I made a change to the file…went to http://localhost and didn’t see it.

I looked back in my terminal and saw that I didn’t have permissions to write to the /www folder.

I started Googling what I need to do to change the folder permissions but wasn’t sure of the right answer (by the way I am not using root as it’s advised to create a new user in Jessie).

However, I remember from a while ago that you can access the webserver files by going to the following path

/var/www/html

When I make a change to this index.php file I see the change on localhost as expected.

I am still looking into this but if someone could share thoughts on what I am missing it would be greatly apprecaited.

Here is my final test showing that PHP is running and the change to the file works.

hello-world

How Do I Set A Static IP Address On Raspbian Jessie

This one stumped me longer than it should have.

If you are familiar with older versions of Raspbian then you are likely use to looking in /etc/network/interfaces to edit static IP configurations.

This has since changed in Raspbian Jessie. I would recommend restoring that file if you have edited it.

In order to set a static IP address on Raspbian Jessie you will need to edit /etc/dhcpcd.conf

To do that simply type sudo nano /etc/dhcpcd.conf

At the bottom of your file you should add the following code…

Of course, you should change your IP address to be whatever you would like for it to be.

The interface eth0 line is for a wired connection (using a network cable).

The interface wlan0 is for a wireless connection (WiFi dongle).

You will need to run sudo reboot for these changes to take place.

Once your Pi has rebooted type in sudo ip addr show look for your interface (wlan0 or eth0) and see if that IP address was changed.

Here is where I got stuck

I admit it, I can be a big NOOB sometimes.

I kept getting 127.0.0.1 as my IP address which looked like a localhost IP address or something.

I am using a WiFi dongle and it hit me, after a clean install of Raspbian Jessie I never connected to my network. So I booted into the GUI (because it’s easier for me) and connected to my Wifi by just clicking the icon in the top navigation bar. Once I found my network and typed in the password I was able to see the static IP address I had specified.

That’s it.

Now I can SSH into my Raspberry Pi.

Recommitted

This was the first blog I put online. I had just graduated college and had no idea what I wanted to do with my career.

I can’t even remember how I learned about the Raspberry Pi foundation but I am glad I did. I bought my first Pi and it opened up a door to me that I ran through. I had only used computers for casual web surfing and video games. But suddenly I wanted to know everything about them, from hardware to software, to network configuration and conf files.

I will be honest, when I first started this site I had no idea what I was doing (I still don’t). At the time I was also trying to learn about SEO.

So if you read any post before this post…I am sorry. Sorry that I didn’t create any other value other than sharing what others had already shared. That wasn’t my intent. I was just trying to figure it all out.

I haven’t published anything on here in a very long time

Part of the reason is I don’t have enough time to create projects with my Pi.

You see, the Pi was the catalyst for my interest in programming. In the last 3 years, I have taught myself how to be a front end developer. In fact, I can make custom WordPress websites now (something that I knew nothing about before starting this blog).

Therefore, a lot of my time is spent working on side projects, client projects, and updating a lot of my personal blogs.

As I transition into a more comfortable work situation I am ready to plug my Raspberry Pi back in and start learning again.

I am excited to see how much knowledge I have gained since my introduction to computing 3 years prior.

The goal of this blog has changed

I likely will not focus any energy on SEO. This site doesn’t get a lot of traffic as is.

But I want to document everything that I am working on related to the Raspberry Pi on this blog. If it’s been covered thousands of times already…sorry.

This likely won’t be the place where you see a ton of awesome projects that require a high level of technical skill.

Instead, I will buy accessories that I have always wanted to try and document my pain points in getting them setup and working properly.

I  will keep the store up but…

You may have noticed that there is a “shop” on this blog.

All it does is pull Amazon information and then uses an affiliate link to redirect you to Amazon to complete your purchase.

Why do I have this on my site?

I thought it would be cool to try out an e-commerce site, and who doesn’t want to make a little beer money off the internet.

So if you are in the market for any Raspberry Pi products and my shop has it, just know it’s all handled by Amazon.

I am going to make it a goal of mine to be more transparent on the shop home page with what is happening.

My biggest hopes for this blog are to have answers to questions that you have and a better overall design sometime early next year.

If you are reading this and want to send some encouragement my way or want me to buy a product to review just let me know in the comments.

Some Raspberry Pi Stats Featured Image

(Infographic) A Brief History Of The Raspberry Pi

The Raspberry Pi Foundation has achieved a number of impressive feats.

The Raspberry Pi has gained the attention of computer lovers and educators across the World.

The community has embraced the small micro computer and developed many amazing projects.

If you are on the fence about buying a Raspberry Pi, then get off the fence and start learning.

The Raspberry Pi is a great tool to learn both computer hardware and software.

So whatever your fancy, enjoy the power of this micro computer like the 5 million other Raspberry Pi users.

Check out this infographic that gives a very quick overview of what the Raspberry Pi Foundation has achieved.

Read more

a-and-b-gpio-numbers

7 Raspberry Pi Sensors

Connecting hardware to your Raspberry Pi is one of the biggest benefits of the $35 mini Linux computer chip. There are a lot of third party companies that make raspberry pi sensors and other external devices that can be paired with the Raspberry Pi to complete your next project.

To connect sensors to your Raspberry Pi you will need to utilize the GPIO (general purpose inpout/output) on the board. These are the upward facing pins next to the video socket on the Raspberry Pi Model B. These pins allow other devices to connect with the Pi physically and allows software to control, manipulate, and report information to your Pi.

Read more

cyan-checklist

38 Super Useful Raspberry Pi Commands

When I first started using my Raspberry Pi I was constantly Googling commands to learn how to use my Raspberry Pi. Learning Raspberry Pi commands is important for interacting with your Pi especially if you want to use the Pi remotely using SSH.

Because the Raspberry Pi is linux based, most of the commands in Linux will work on the Raspberry Pi. For a Raspberry Pi beginner this might not make any difference because you don’t know any linux commands. That is okay. These 38 super useful Raspberry Pi commands will help you navigate your Pi, edit critical files, move files, network your Raspberry Pi and much more.

Read more

amber-code

Raspberry Pi OS For Beginners

Getting a Raspberry Pi up and running is easy. All you need is a Raspberry Pi, a power supply, a keyboard, mouse, monitor, and SD card. The hard part is deciding which operating system to install on your Raspberry Pi to launch your first project.

Luckily there are a lot of choices when selecting a Raspberry Pi operating system. Because Linux is an open source system, all of the Raspberry Pi OS are free.

This is nice because you can try all the flavors without worrying about cost.

So here is a breakdown of Raspberry Pi projects/OS for beginners.

If you don’t know which Pi operating system to download or want to try something else. Check out your options.

Read more

Voice Activated LED Coffee Table Powered By Raspberry Pi

This is cool. We love LED lights here at RaspiBakery, and any project that uses LED lights in a cool way.

We also like DIY projects that merge functionality, technology, and furniture. So today, we want to share with you an awesome project from Mikel Duke who used an Arduino and a Raspberry Pi to make an interactive LED coffee table.

You can check Mikel’s video out here.

Read more

teal-camera

5 Of The Best Raspberry Pi Projects For Young Kids

Here are 5 awesome ideas to teach kids the power of computing and programming with a Raspberry Pi.

Originally the Raspberry Pi foundation created the small $35 computer chip to help teachers and students learn the basics of computers. Since then many adults have embraced the power of the small computer. The ability to run multiple Linux distributions and reliably run applications makes the Raspberry Pi the perfect piece of equipment for young kids to learn computing projects.

This list will break down 5 of the very best Raspberry Pi projects for young kids.

Read more

Hands Holding Controller

Top 3 Raspberry Pi Accessories You Gotta Have

I have three Raspberry Pi’s and they work great.But I find myself adding more Pi’s and Raspberry Pi Accesorries into my shopping cart. I don’t know what it is.

Well actually I do, the problem is there are so many cool looking projects that I want to try and too many new accessories for the Pi. But I don’t want to partition my SD cards and run the risk of ruining a project that is running fine.

So I would rather take the easy way out and buy another Pi or Raspberry accessory. Sure it cost a little more but heck, I love tinkering with them, and have tons of peripherals laying around, so why not.

Through all of the Raspberry Pi projects I have found these Raspberry Pi accessories to be the most handy, novel, and fun items to go along with a Raspberry Pi.

Read more

The Ultimate Guide On How To Make A Raspberry Pi Media Center

The Ultimate Guide On How To Make A Raspberry Pi Media Center

A lot of Raspberry Pi users creating XMBC media centers with their Pi’s. Honestly this project always appeared too simple for me and when I first got my Pi I wanted to try much more challenging projects. I thought a media center was too easy because you already had everything nicely bundled as an image and you basically just put the SD card in boot up the Pi and viola you are running an XMBC media center. I finally got the itch to give it a try. I mean everybody else is running a media center I should probably have one. After all, if you drink the Pi kool-aid you better try a media center.

Read more

What To Do With A Raspberry Pi

Want to buy a Raspberry Pi? Not sure what to do with a Raspberry Pi? Here is a guide for beginner for some ideas on a Raspberry Pi project. This post will detail some of the most popular, widely supported raspberry pi projects. Hopefully this post will give you an idea of what and how to set up a Raspberry Pi once you decide to buy one. Check out these popular projects.

Read more

indigo-magician

Magic Mirror Raspberry Pi Project

Mirror Mirror On The Wall

The magic mirror raspberry pi project is perfect if you are looking for a project to bring technology and functionality together. Michael Teeeuw at Xonay Labs has created a Magic Mirror Raspberry Pi Project that looks clean and serves a unique purpose. What is most impressive about this project is hiding all of the cords associated with powering and displaying the output of a Pi behind a one way mirror. No doubt making the mirror frame took some skill as well. This post will review his mirror project as well as a new take on the magic mirror, with a free download for a web interface to display on your very own RPI mirror project. Below is Michael’s completed Magic Mirror with the time, weather, and a motivational quote.

Read more