Skip to main content

Cómo hacer un Web Server con una Raspberry Pi B+

Si ocupas tener o montar una pequeña página web, para una aplicación simple en particular, con un bajo nivel de concurrencia y no se quiere gastar mucho dinero en ello o es una solución temporal?. Estás leyendo el post correcto, pues acá vas a obtener una solución simple mediante el uso de una Raspberry Pi, en pocos pasos.

Precondiciones

  1. Tener acceso a internet (Ethernet o Wi-Fi).
  2. Hardware usado: Raspberry Pi B+ (debería funcionar para cualquier familia de Raspberry Pi u otro hardware).
  3. Sistema Operativo usado: Raspbian
  4. Para ejecutar el ejemplo se necesita: una resistencia (1 KΩ), un LED, una protoboard y cables para conectar a los pines de la Raspberry Pi (en el ejemplo se usa el GPIO 2).

Pasos:

Únicamente debe ejecutar estos simples comandos en la terminal de la Raspberry Pi:
# Actualizar su Raspberry Pi
sudo apt-get update && sudo apt-get upgrade
# Instalar Apache
sudo apt-get install apache2
# Instalar PHP
sudo apt-get install php5 libapache2-mod-php5
# Reiniciar el servidor de Apache
sudo service apache2 restart
Ahora tienes un Servidor Web corriendo en su Raspberry Pi. Para comprobar el correcto funcionamiento del mismo, tan sólo debes ir a la dirección /var/www  y ahí encontrará el archivo index.html y si quiere ver esto en un navegador de la RPI, ingrese localhost o 127.0.1.1 en el mismo (ver imagen abajo), o sea, ahí se alojará su nueva página web.
Por otro lado, si su computadora o teléfono celular está conectado a la misma red local de la RPI, con la Ip de la PRI la puede ingresar en cualquier navegador para observar la misma página web, como se muestra en la imagen de abajo: 

Ejemplo de una aplicación usando un Servidor Web en la RPI

Te gustaría hacer una aplicación web para controlar el bombillo de tu cuarto o cualquier otro dispositivo de tu casa?. En este ejemplo se explicará como desarrollar esto, pero se va a usar un LED simulando el funcionamiento de un bombillo.

Pasos:

Ejecutar estos simples comandos en la terminal de la Raspberry Pi:
# Para dar permisos, añada al final del archivo: www-data ALL=(ALL) NOPASSWD: ALL
sudo visudo
# Descargar script de instalación del Demo
sudo wget --no-check-certificate https://www.dropbox.com/s/kxsquph5afbguo0/ncubo.zip?dl=0
sudo apt-get install zip
mv ncubo.zip?dl=0 ncubo.zip
unzip ncubo.zip
cd ncubo/
sudo chmod +x -R *
sudo ./ncubo.sh
Una vez ejecutados estos pasos sin problemas, la página web del demo está alojada en la dirección /var/www, lista para ser consultada. 
Notas:
  • Esto funciona sólo en su red local, si quiere acceder a la aplicación de forma remota, puede usar una VPN ( ver el siguiente post).
  • Para hacer las pruebas con bombillos de alto voltaje, se necesita un Relay, donde este sea accionado por la RPI, permitiendo el paso de la corriente alterna al bombillo, sin dañar la RPI.
Agradezco a Ncubo por brindarme el equipo necesario para realizar el post.

Popular posts from this blog

ISTQB - Foundation Level Agile Tester Recap

ISTQB - Foundation Level Agile Tester Recap This is a summary that will help you to approve the Agile Tester certification test. 1 - Agile Software Development 1.1 - The fundamentals of Agile Software Development  The Agile Manifesto has 4 values : - Individuals and interactions over processes and tools (people-centered) - Working software over big documentations (time to market advantage) - Customer collaboration over contract negotiation (customer requirements) - Responding to change over following plan (change is more important)   The Agile Manifesto has 12 principles : - Satisfy the customer with continuous delivery - Changing requirements - Deliver software frequently (few weeks or months) - Business people and developer must work together - Build projects around motivated individuals - Face to face conversation - Working software is the primary measure of progress - The team should maintain a constant pace indefinitely - Technical excellence and good design - Simplic

RasPI Assistant: Google Assistant + Dialogflow + Raspberry Pi

Would you like to control the TV using your voice without spend a lot of money? ... Amazing right?. So, in this post, I will teach you how to do that and more. Some of my dreams always have been control things without touch them, for example: the television, due to tired to raise the hand to change the channel. So ... let's create a device that can do this action automatically. What things will we need? First, I should understand the problem and be aware about it. For example: if we want to control a TV that is not smart, how will we do that? ... a possibility is to send infrared signals (IR) to transmit the events that the person's desire. Also, if I want that the device can hear me, I may need a microphone. Additionally, it should have a speaker to talk with the people. Further, I will need a database to save all the information, APIs that can help me with the smart logic and cheap electronic components like a Raspberry Pi , resistors, leds, wires an

How to create a simple Chatbot?

Developing an amazing Chatbot ... What is a Chatbot? First to understand how it works, you need to know how it was originated and some algorithms  like  the Natural Language Processing (NLP). It is another AI area, but it is around the language (usually written), it is the component that bridges the gap between human conversation and understanding programmed by a computer. NLP allows the computer to interpret the vast and complicated human language, understand it, process it, and effectively "speak", just like humans. Through the process, the machine has to understand all the jargon that is being using and developing or adapting with the ability to respond, as a human computer. NLP has to do with the creation of systems that process or "understand" the language to perform certain tasks, such as answering questions, analyzing the sentiment in a sentence, making translations between different languages, and another. In the past, the NLP involved a lot