Introduction
In this article, we will cover the process of configuring two Ubuntu servers to create a local area network (LAN) with Apache, a mail server, Nextcloud, and Samba for file sharing. The servers will run Kubuntu 22.04 and will host two domains, one for the mail server and one for Nextcloud.
Setting up the LAN
To set up the LAN, you will need to connect both servers to a switch or router using Ethernet cables. Once connected, you will need to configure the network interfaces on both servers. This can be done by editing the /etc/network/interfaces file on each server. Below is an example configuration for a static IP address:
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
Replace the IP address, netmask, and gateway with the appropriate values for your network. Once the network interfaces are configured, you can test the connection by pinging one server from the other.
Installing Apache
To install Apache, run the following command on both servers:
sudo apt-get update
sudo apt-get install apache2
Once Apache is installed, you can start the service and enable it to start on boot with the following commands:
sudo systemctl start apache2
sudo systemctl enable apache2
You can test the installation by opening a web browser and navigating to http://server.ip.address.
Setting up the Mail Server
To set up the mail server, we will use iRedMail, a full-featured mail server solution. To install iRedMail, follow the instructions on the iRedMail website.
Once iRedMail is installed, you can access the web-based administration panel at https://mail.yourdomain.com:8443.
Installing Nextcloud
To install Nextcloud, first, install Apache and MySQL:
sudo apt-get install apache2 mysql-server
Next, download the Nextcloud package and extract it:
wget https://download.nextcloud.com/server/releases/nextcloud-22.0.0.zip
unzip nextcloud-22.0.0.zip
Move the extracted files to the Apache web root:
sudo mv nextcloud /var/www/
Create a new MySQL database and user for Nextcloud:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Next, open a web browser and navigate to http://yourdomain.com/nextcloud to complete the installation.
Installing Samba
To install Samba, run the following command:
sudo apt-get install samba
Once Samba is installed, you can create a new Samba share by editing the /etc/samba/smb.conf file and adding the following configuration:
[share]
path = /path/to/share
read only = no
browseable = yes
Replace /path/to/share with the actual path to the directory you want to share. Once the configuration is added, restart the Samba service:
sudo systemctl restart smbd
In this article, we covered the process of configuring two Ubuntu servers to create a LAN with Apache, a mail server, Nextcloud, and Samba for file sharing. The servers were running Kubuntu 22.04 and were hosting two domains, one for the mail server and one for Nextcloud. By following the instructions in this article, you should be able to set up a similar configuration in your own environment.
References