Luck is what happens when Preparation meets Opportunity. Lucius Annaeus Seneca 4BC-65AD
This is the standard installation of Raspbian. It is described in detail much better than I can in the following links:
MagPi - How to set up Raspberry Pi 4
Raspberry Pi foundation - Setting up your Raspberry Pi
The set up of the microsd card for Raspbian and boot loader updates can be done from Windows, Mac or Ubumtu using Raspberry pi imager which can be downloaded. Instructions are in: Raspberry Pi OS
This step enables the Raspberry PI to start up from a USB connected disk instead of the memory card. It involves updating the firmware on the Raspberry PI.
See: tom's HARDWWARE - How to Boot Raspberry Pi 4 / 400 From a USB SSD or Flash Drive
and: Adafruit - Using an External Drive as a Raspberry Pi Root Filesystem
After this you should have a working Raspberry PI which boots from a USB connected disk and is connected to the internet. You should verify this and if there is a problem then debug and resolve it. With a mouse, keyboard and screen attached it should power up normally to the main screen.
The next stage is more interesting with the installation of software for the web site and email.
For the Apache installation and configuration
see: PiMyLifeUp - How to Setup a Raspberry Pi Apache Web Server
Apache can be installed on the Raspberrry pi with command:
sudo apt install apache2 -y
Once you have done this and rebooted if you go onto another computer in the same network and in the web browser type in the IP address of the raspberry pi server you should see the default Debian web screen. (You can get the IP address, at the command prompt, enter ifconfig, eth0 is the ethernet, wlan0 is the wifi). If you cannot get the default Debian web screen then you need to go back and debug and resolve it.
Depending on what your web site is created with and uses you will need to install other support packages. For mine I need mysql and php. This is the so called “LAMP” installation, Linux, Apache, mysql, php.
For mysql installation and configuration assistance please see:
PiMyLifeUp - Setup a Raspberry Pi MYSQL Database
To install mysql use:
sudo apt install mariadb-server
You will be asked some questions so follow the instructions from the link
To install php use:
sudo apt install php8.2 libapache2-mod-php8.2 php8.2-mbstring php8.2-mysql php8.2-curl php8.2-gd php8.2-zip -yPhpmyadmin allows you to manage mysql via a web interface and is much easier than the command line interface. See the link below for details
PiMyLifeUp - How to Install PHPMyAdmin on the Raspberry Pi
To install phpmyadmin use:
sudo apt install phpmyadmin
Note this install is specific to POP3. If you are using IMAP it is likely to be different.
sudo apt install dovecot-imapd dovecot-pop3d
The command to install postfix is:
sudo apt-get install postfix
You will see a menu with some choices. Select “Internet Site” and then set the mail name to your domain name, not including www. (e.g. example.com). The setup script will then do some automatic configuration for you.
See the following link for help with installation and configuration:
PiMyLifeUp - Raspberry Pi SSL Certificates using Let’s Encrypt
As we are using Apache the command to install letsencrypt is:
sudo apt install python3-certbot-apache