

- Raspberry apache server tutorial how to#
- Raspberry apache server tutorial install#
- Raspberry apache server tutorial update#
- Raspberry apache server tutorial Pc#
- Raspberry apache server tutorial download#
Raspberry apache server tutorial install#
As a basis I took the NPM package rpio.įor a simple test, you can clone the GitHub package: git clone īefore we start the server, the other packages have to be installed: npm install However, it is also easy to define GPIOs as inputs and to read them out. Since this is only a small example, the output can only be controlled.
Raspberry apache server tutorial Pc#
I have written a small application that allows you to control your GPIOs via the web interface (desktop PC browser, smart phone, tablet). If your sample file is still running, you can terminate it by pressing CTRL + C. If you want to use a new package (in our case it is rpio) you can specify the parameter -save and the package will be automatically added to the package.json file: npm install rpio -saveįor further instructions and explanations, you can take a look at the NPM documentation.Ĭontrol Raspberry Pi GPIOs via web interface However, it is not absolutely necessary that you enter your used packages by hand. To do this, change to the directory where the package.json is located and enter: npm installĪll necessary packages are installed.
Raspberry apache server tutorial download#
If you use / download another project, the required packages must first be installed. In this file “dependencies” are used to specify the packages used (minimum required). Typically, a created project has a file named “package.json” in the root directory. With the help of the NPM (Node.js Package Manager), additional libraries can be easily installed and used in a node project. Of course, the selected ports must also be selected and enabled in your router via port forwarding for the internal IP address of your Raspberry Pi. If you want to permanently access the server from outside your home network, it makes sense to install a DNS server.

However, Node.js requires root privileges for ports that are less than 1000. For me, this is PS: We use port 8000 in this example.

Enter either the IP of your Pi in the network including the port (e.g., 192.168.1.68:8000) or (if your router supports it) simply the name of the host including port. You can now view the page in the browser. You can now start the server simply by entering the following in the terminal: node hello-world.js We then save and close the editor (CTRL + O, CTRL + X). createServer ( function ( request, response ) ) server. Var http = require ( 'http' ) var server = http. Now let’s begin with a little Hello-World! program. The latest version should now be displayed. If the installation went through without any problems, we can simply write the following in the console to see if everything has worked: node -version Now we can easily install Node via the internal package manager, which may take a little time: sudo apt-get install -y nodejs The latest LTS version can be viewed on the Node.JS website and adapted accordingly. Since Node.JS is not in the predefined package sources, we must add it first.
Raspberry apache server tutorial update#
Installation of Node.JS on the Raspberry Piīefore we install Node, we update the packages and package sources to have everything you need: sudo apt-get update In addition, I recommend using the SSH access, as well as optimally from an FTP service, to simply transfer files to the Raspberry Pi. In order to be able to reproduce the small example at the end, the following hardware is also required: I recommend for this a FRITZ!Box or similar. In addition, your router must support portforwarding, if you want to call the applications outside of your home network. Many other projects, for which a server is needed, can also be realized with a Raspberry Pi and NodeJS.īecause of the better performance compared to the previous versions and especially because of the ARMv8 architecture, I recommend a Raspberry Pi 3. In addition, I have written a small program for Node, which can control the GPIOs of the Raspberry Pi.Ī NodeJS server is a prerequisite for many different applications, such as HomeBridge.
Raspberry apache server tutorial how to#
This tutorial shows you how to set up and configure a Raspberry Pi NodeJS server. In addition to the advantages of asynchronous applications, Node.JS offers a very simple but powerful method to install and use different plugins or libraries, using the internal package manager “npm”.

Originally developed for the Google Chrome browser, it is very resource-efficient, which makes the use of a Raspberry Pi Node.JS web server interesting. Node.JS is a server platform that uses JavaScript.
