To assign separate unique IP addresses to different domain names on a Linux hosting server, you need to configure your server's network and web server to bind each domain name to a specific IP address. Here’s how you can achieve this:
---
### **Step 1: Assign Multiple IP Addresses to the Server**
1. **Add IP Addresses to the Network Interface**
Edit your network configuration file to include the additional IP addresses. For example, on systems using `netplan`, you can edit `/etc/netplan/*.yaml` to add IP addresses like this:
```yaml
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.10/24
- 192.168.1.11/24
- 192.168.1.12/24
```
Apply the changes:
```bash
sudo netplan apply
```
2. **Verify the Configuration**
Ensure the additional IPs are assigned using:
```bash
ip addr show
```
---
### **Step 2: Configure the Web Server**
You need to configure your web server (e.g., Apache or Nginx) to bind each domain name to a specific IP address.
#### **For Apache**
1. Edit your virtual host configuration files, typically located in `/etc/apache2/sites-available/`.
2. Define a virtual host for each domain and bind it to a specific IP:
```apache
<VirtualHost 192.168.1.10:80>
ServerName domain1.com
DocumentRoot /var/www/domain1
</VirtualHost>
<VirtualHost 192.168.1.11:80>
ServerName domain2.com
DocumentRoot /var/www/domain2
</VirtualHost>
```
3. Enable the virtual hosts:
```bash
sudo a2ensite domain1.conf
sudo a2ensite domain2.conf
```
4. Restart Apache:
```bash
sudo systemctl restart apache2
```
#### **For Nginx**
1. Edit your server block configuration files, typically located in `/etc/nginx/sites-available/`.
2. Define a server block for each domain and bind it to a specific IP:
```nginx
server {
listen 192.168.1.10:80;
server_name domain1.com;
root /var/www/domain1;
}
server {
listen 192.168.1.11:80;
server_name domain2.com;
root /var/www/domain2;
}
```
3. Enable the configurations by creating symbolic links:
```bash
sudo ln -s /etc/nginx/sites-available/domain1 /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/domain2 /etc/nginx/sites-enabled/
```
4. Test and reload Nginx:
```bash
sudo nginx -t
sudo systemctl reload nginx
```
---
### **Step 3: Update DNS Records**
Ensure the DNS records for each domain point to the assigned IP address:
- For `domain1.com`, set the A record to `192.168.1.10`.
- For `domain2.com`, set the A record to `192.168.1.11`.
You can configure this through your domain registrar's DNS management panel.
---
### **Step 4: Test Your Configuration**
Verify that each domain resolves to its specific IP address using tools like `ping` or `curl`:
```bash
ping domain1.com
ping domain2.com
```
---
### **Optional: SSL/TLS Configuration**
If you are using HTTPS, set up SSL certificates for each domain, ensuring they correspond to their unique IP address.