قالب وردپرس درنا توس
Home / Tips and Tricks / Put a test server on Raspberry Pi – CloudSavvy IT

Put a test server on Raspberry Pi – CloudSavvy IT



The Raspberry Pi started out as a low-cost device to help students learn about computers, but the Raspberry Pi is also a low-cost test server. With a server operating system on a Raspberry Pi, you can quickly set up a test server at home.

I recently decided to reinstall my Raspberry Pi 3B + to use as a test server for new web projects. My production environment is an Intel rack server running Red Hat Enterprise Linux, so it doesn̵

7;t really match the Raspberry Pi at the hardware level. But at the application layer, Linux on Raspberry Pi is still “Linux”, Apache on Raspberry Pi is still “Apache”, and PHP 7 on Raspberry Pi is still “PHP 7.” As long as my Raspberry Pi is set up as a server, rather than a desktop-oriented Linux distribution, my work on the Raspberry Pi will transfer to my production environment with Red Hat Enterprise Linux on Intel quite easily.

While there is no Red Hat Enterprise Linux for Raspberry Pi, Fedora Server is close enough for my needs. I tried installing Fedora 33 ARM Server on the Raspberry Pi, but I couldn’t get wireless networking to work out of the box, despite a note on the Fedora ARM page that wireless networking is supported by default on Fedora 33. The problem seems to be that that Fedora 33 does not include ARM Server wpa_supplicant However, I was able to get everything working by installing Fedora 33 ARM Minimal.

Download the Fedora 33 ARM Minimal image from the Fedora ARM website. You can find the download location in the wiki. Specifically, to install Fedora 33 Minimal on the Raspberry Pi 3, you need to download Fedora-Minimal-33-1.3.aarch64.raw.xz from the aarch64 supported image for Raspberry Pi 3.

Once you have the Fedora 33 Minimal image, you can install it on a microSD card to boot onto the Raspberry Pi later. Connect your microSD card to your Linux workstation or server and run this command:

# arm-image-installer --image=Fedora-Minimal-33-1.3.aarch64.raw.xz --media=/dev/sdb --target=rpi3

That command writes the Fedora 33 Minimal image to the microSD card. My Linux desktop PC does not have a built-in microSD slot, so I used a USB microSD card reader, which presents the microSD on /dev/sdb Depending on your system, you may need to use a different media target device.

Installing Fedora 33 Minimal on the microSD essentially dumps a pre-installed image to the card. You will need to do all the post-configuration when you first boot the microSD into the Raspberry Pi.

Connect your Raspberry Pi to an HDMI display and USB keyboard, plug in the microSD and turn it on. The first boot will take a while while it performs some initial setup tasks, where Fedora will prompt you for local settings including time zone, root password and user account.

Once my system was up and running, I was able to log in if the root user. Since I don’t have a network cable long enough to reach this Raspberry Pi, I had to set up a wireless network. Run the Network Manager command line tool at the command line nmcli to view the available wireless networks:

# nmcli device wifi list
nmcli device wifi list command
Use nmcli to view the available wireless networks

If nmcli finds your wireless network and connects to it nmcli “Connect” command. To replace $SSID with your wireless network name:

nmcli device wifi connect $SSID --ask

After that, Network Manager will automatically create an entry for you under the /etc/NetworkManager/system-connections directory so that the system connects to this network every time you boot the Raspberry Pi.

Since I’m running the Raspberry Pi as a server on my home network, I also have to make sure that the Raspberry Pi gets the same IP address every time it connects to the network. On a home network, you can do this through your wireless router. Most routers allow you to recognize a MAC address and assign it a reserved IP address. My home router gives out IP addresses starting at 10.0.0.100, so I gave the Raspberry Pi a reserved IP address under that range, at 10.0.0.11:

Assign the Raspberry Pi its own IP address

I find the easiest way to manage my Linux systems is with the Cockpit tool. Cockpit makes it easy to control your Linux servers through a web browser, allowing you to view logs, manage storage, set up user accounts and install services. Fedora 33 ARM Minimal does not install Cockpit by default, but you can easily install it as a package with dnf

dnf -y install cockpit

After installing Cockpit, make sure the Cockpit service is running and restarted when you reboot the system. Fedora uses systemd , so you need to start the service and enable it for every restart with these two “system control” commands:

# systemctl start cockpit
# systemctl enable cockpit.socket

Fedora’s default firewall prevents connections to your device, so you must also open the port on the local firewall to accept connections to Cockpit. You can add the Cockpit service with the firewall-cmd command line tool:

# firewall-cmd --add-service=cockpit --permanent
# firewall-cmd --reload

Now you should be able to navigate to https://10.0.0.11:9090/ in your web browser to remotely control your Raspberry Pi.

Manage your system with Cockpit

Cockpit allows you to perform any other system setup tasks you may need. To finish setting up this Raspberry Pi as a web server I installed the Apache httpd webserver and PHP 7, and then used Cockpit to fine-tune everything to my production system as best as possible:

Manage httpd with Cockpit

You don’t need an expensive server to set up a robust test server environment. With a server operating system such as Fedora 33 ARM Minimal, you can quickly set up an inexpensive home testing server on a Raspberry Pi. And with Cockpit, you can manage everything right from your browser.


Source link