Introduction
All of our servers will start with this install. This base server is based on Ubuntu 20.04 LTS Server. I don’t explain much in the howto so if you have a question leave a comment or use Google.
Downloading the ISO
Visit the Ubuntu website and download the ubuntu 20.04 server ISO.
Initial Install
The install screens are straight forward. I’m not going to cover them in much detail. Unless you need to customize a setting, just choose the default settings. Boot the install DVD.
Click ‘Reboot’ when it appears.
First boot
Reboot the machine when the install finishes.
The OS will boot. Log in. All the commands need to be run as root so lets start a shell with root privilleges.
> sudo bash
Get everything updated and install a couple of items.
> sudo apt update
> sudo apt dist-upgrade
Install and enable ssh.
> sudo apt install ssh
> sudo systemctl enable –now ssh
WARNING: My server isn’t directly connected to the internet. The firewall is disabled to help with installation, configuration and testing easier. Once everything is working, turn on the firewall and configure it. I wil remind you to secure your server at the end of this howto.
now reboot the server.
The Second Boot – Installing Additional Packages
We need quite a few other packages. In this howto I’m installing packages regardless if they were already installed by another dependency. This guards against package changes that could cause a package to not be installed. Once again log in to your server.
We need the webmin repo. Create webmin.repo with the text below.
> sudo nano -w /etc/apt/sources.list.d/webmin.list
deb http://download.webmin.com/download/repository sarge contrib
Install the webmin key.
> wget http://www.webmin.com/jcameron-key.asc
> sudo apt-key add jcameron-key.asc
Let’s add a 3rd party repo for Apache.
> add-apt-repository ppa:ondrej/apache2
Now bring everything up to date.
> sudo apt update
Install the following packages. Multiple lines to make cut and paste easier.
> sudo apt install make screen snmp composer libcurl4 unzip net-tools
> sudo apt install apache2 libapache2-mod-php7.4 mysql-server mysql-client
> sudo apt install libapache2-mod-fcgid php-opcache php-apcu
Install some extra PHP libraries.
> sudo apt install php7.4-gd php7.4-snmp php7.4-mbstring php7.4-mysql
> sudo apt install php7.4-odbc php7.4-imap
> sudo apt install php7.4-xmlrpc php7.4-dba
> sudo apt install php7.4-soap php7.4-zip php7.4-intl php7.4-curl
Now lets install webmin.
> sudo apt install webmin
> sudo systemctl enable webmin
> sudo service webmin start
Configure Apache and PHP
Enable the rewrite module.
> sudo a2enmod rewrite actions fcgid alias proxy_fcgi expires headers
Enable Apache.
> sudo systemctl enable apache2.service
Reload apache.
> sudo systemctl restart apache2.service
Configuring MySQL
Configure mysql.
> sudo mysql_secure_installation
Installing and Configuring phpMyAdmin
I prefer to phpMyAdmin to manage my MySQL databases.
Now install phpMyAdmin.
> sudo apt install phpmyadmin
Restart Apache.
> sudo systemctl restart apache2.service
Installing Postfix
Lets install postfix.
> sudo apt install postfix
When prompted select internet site. Next set the mail server name.
Installing cockpit
I’m trying cockpit as my server admin tool. Do the following to set it up.
> sudo apt install cockpit
> sudo systemctl start cockpit
> sudo systemctl enable cockpit.socket
You can now login to https://yourserver.tld:9090 to administer your server.
Getting root’s and other’s mail
You need to get some local system user’s mail. We’ll use postfix’s virtual file to get the emails to the right place.
Add the following to /etc/postfix/virtual
root admin@yourdomain.tld
postmaster admin@yourdomain.tld
abuse admin@yourdomain.tld
Now add the configuration option to main.cf
> sudo postconf -e “virtual_alias_maps = hash:/etc/postfix/virtual”
Just a couple commands to wrap everything up.
> sudo postmap /etc/postfix/virtual
> sudo systemctl restart postfix
> sudo systemctl enable postfix
Remove Cloud Init
Our server won’t be using cloud-init. To keep from causing you trouble in the future we will remove it now.
Type:
> sudo apt remove cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf
Final Settings
You may want to enable the linux firewall.
Set your timezone in /etc/php.ini
Conclusion
That’s it for the basic server setup. This is an example of a standard linux server setup. Be sure to use cockpit or webmin to set which services you want to start at boot time. See the other pages for info on configuring servers for virtual webhosting or virtual email hosting. Remember to configure the firewall on the server.