Host multiple apps on your Raspberry Pi

Do you know that you can host multiple apps on your Raspberry Pi and access them from outside your network? I understand that the Raspberry Pi may not be powerful enough for database-related transactions, but you can still host simple and lightweight apps on it to enhance your productivity. In this article, I will show you how to host multiple web apps on your Raspberry Pi machine using Apache as a web server.

If you wish to install Nextcloud on your Raspberry Pi, you can follow this article.

Install web server

Option 1

To install the LAMP (Apache, MariaDB, and PHP) stack, follow this article from step 2 to step 4. The rest of the steps are dependent on your requirements.

Option 2

However, we can just install Apache for static sites.

apt install apache2 zip unzip

a2enmod ssl rewrite headers proxy proxy_http deflate cache proxy_wstunnel http2 proxy_fcgi env expires

Enable Apache at boot time and restart it.

systemctl enable apache2
systemctl restart apache2

Before we proceed

If you want to access your sites over a dynamic IP, follow this guide to set it up with Cloudflare. Skip this step if you already have a static IP.

To run these sites exclusively on your network, add them to the /etc/hosts file and skip the SSL setup below. In this case, the DOMAIN.COM (Apache virtual hosts) corresponds to portfolio.local and startup.local.   portfolio.local   startup.local

Create multiple hosts

If you want to install any database-related web app, such as WordPress, Moodle, or Nextcloud, follow its respective guide. You don’t need to follow the entire guide; read through and follow the parts that are required, such as the database, download section etc.

For the sake of this guide, we will keep things simple and create two static sites with only one page. Let’s call them portfolio (site 1) and startup (site 2).

cd /var/www/html

rm index.html

mkdir portfolio
mkdir startup

Portfolio website

We will create an index.html file in it and start with the basics. You can push your own files to it or enhance it accordingly.

cd /var/www/html/portfolio
touch index.html
vim index.html

Paste the following in it:

<!DOCTYPE html>

      <p>Hi, my name is Admin.</p>


Save this and change the ownership of this directory.

chown -R www-data:www-data /var/www/html/portfolio

Now, we will create a virtual host file. Switch to sites-available directory and create a portfolio.conf file.

cd /etc/apache2/sites-available
vim portfolio.conf

Paste the following into it while changing the domain name.

<VirtualHost *:80>
	ServerName DOMAIN.COM

	DocumentRoot /var/www/html/portfolio

	<Directory "/var/www/html/portfolio">
		AllowOverride All
		Options -Indexes +FollowSymLinks

	ErrorLog /var/log/apache2/portfolio_error.log

Enable this configuration:

a2dissite 000-default.conf
a2ensite portfolio.conf

apachectl -t
systemctl reload apache2

Now, if we browse the domain in a browser, we will see a basic page like the one below.


Startup website

The process is almost the same as the portfolio website. Simply create an index.html file or push your own files to the /var/www/html/startup directory. Additionally, create a virtual host configuration file named startup.conf in the /etc/apache2/sites-available directory.

Once you are done, you can enable this site and restart Apache.

a2ensite startup.conf

apachectl -t
systemctl reload apache2

You will now be able to see the site in the browser using the domain you selected.


This is optional, but if you have a static IP or are using DDNS to access your sites outside your network, it is good to have SSL in front of them.

Please note that the IP should be pointed to the domains for this to work.

Follow the section from ‘How to install Nextcloud on Raspberry Pi‘ to obtain free certificates from Let’s Encrypt.

Once you have successfully retrieved the certificates, you can update the virtual host files with them. Follow this section to learn how to update them. Make changes where necessary, such as the path to the document root, path to certificates, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *