RaspberryPi 4 – webserver

For a few years I have had a RaspberryPi 3 running with php 5.6, 7.1, apache, webmin and virtualmin. On it some scanning software, websites and a package repository. This is all working well ( for light use ). But there are a few issues: no support for the latest versions of php and .. a bit limited (specs). I saw the launch of the raspberry pi 4 and was amazed by the specs.. so I got the one with 4GB.

== project in progress // not succesfull ==

The RaspberryPi 3 took me a month to setup, trying everything from noobs to ubuntu. I ended with the minimum raspbian version and as mentioned above virtualmin. Most packages installed flawless on the Pi3 as it had been there for a while. Now I amm struggeling on the RaspberryPi4 and thought to make a post of tried options and ultimatly the how to. ( work in progress )


    • PHP 7.2 and 7.3
  • Webserver
  • Let’s encrypt, mail etc

So the first thought was to replicate my pi3 setup. Problem was (july 2019) Virtualmin is not yet supported on Debian 10 Buster ( the new raspbian base ). Although I did not even start yet, I dropped the idea of Virtual min ( check if it is supported support link ), and focussed on ISPConfig.

Start by prepping your SD

I have used:

  • SDFormatter to format the SD and set FORMAT SIZE ADJUSTMENT to on. This way raspbian can expand the use of the SD to it’s full capacity.
  • I used belenaEtcher to flash the latest downloaded Raspbian version on the SD.
  • You could place a file on the SD with the name SSH and no extension in the boot partition, this would enable you to connect to the RaspberryPi with ssh (user: pi, password: raspberry).

It does not really matter which raspbian distribution you use. Raspbian full, desktop or lite.

Setup the Raspbian OS

After inserting the SD in the Pi and pluging in the powersupply you can boot it up. Next you will either have to login with a keyboard and mouse on the RaspBerryPi or connect with ssh. Either way here are some of the tasks you could run:

  • Most setups wil ask to change the password for pi but you can also create a new user and remove pi or rename the user pi.
  • If you run ‘raspi-config’ in a shell you can:
    • under advanced options: expand the filesystem ( use full capacity sd)
    • under update, update the raspbian config

Before more steps it might be advisable to do a system update. Run the following commands:

  • sudo apt-get update
  • sudo apt-get dist-upgrade

Start setting up the server

First off we change the hostname:

  • sudo nano /etc/hosts
    Add a line with the ip for the pi, a fulldomain name and the subdomain one more time
    example:   server.test.com server
  • sudo nano /etc/hostname
    add only the subdomain: server

Now the commands

  • sudo hostname
  • sudo hostname -f

Second the following commands:

  • For postfix: sudo apt-get -y install postfix postfix-mysql postfix-doc
    Give an enter if anything is asked (indernet-site for the first answer en the result you got for hostname -f for the second)
  • For mariadb: sudo apt-get -y install mariadb-client mariadb-server
  • Some bundle: sudo apt-get -y install openssl getmail4 rkhunter binutils
  • And devcot: sudo apt-get -y install dovecot-imapd dovecot-pop3d dovecot-mysql dovecot-sieve dovecot-lmtpd
  • Finish mysql setup: mysql_secure_installation

Rest from step 9: