I have currently one website running perfectly on my LAMP server (Ubuntu Server 16.04.3).
I now would like to add another one to the server. So i first went to the /etc/apache2/sites-available file and copied the 000-default.conf file to the same directory while changing the name to mydomainname.com.conf.
Then i edited this file to the following:
<VirtualHost mydomain.com:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin admin.mydomain.com
DocumentRoot /var/www/mydomain.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Next i typed the command a2ensite mydomain.com.conf
Than i restarted apache.
Then I mkdir /var/www/mydomain.com/public.html (Also changed the permissions)
After this i edited the /etc/hosts file and added:
127.0.0.1 mydomain.com.
myinternalIP mydomain.com
myStaticIp mydomain.com
I then added the internal IP for the new site and also the public IP for the new site here.
Then I went to the /etc/network/interfaces file:
The loopback network interface
auto lo
iface lo inet loopback
- The primary network interface(this is for the virtual host already on the server)
auto eno1
iface eno1 inet static
address 192.168.11.199
netmask 255.255.255.0
network 192.168.11.0
broadcast 192.168.11.255
gateway 192.168.11.59
dns-nameservers 8.8.8.8
dns-search currentsite.com
-Second IP interface(This is for the new virtual host)<br>
iface eno1:1 inet static
address 192.168.11.200
netmask 255.255.255.0
Output when I do an Ifconfig:
eno1: Link encap: Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.11.199 Bcast:192.168.11.255 Mask:255.255.255.0
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
TX packets:6085 errors:0 dropped:0 overruns:0 carrier:364
collisions:381 txqueuelen:1000
RX bytes:563896 (563.8 KB) TX bytes:5541282 (5.5 MB)
Interrupt:20 Memory:f7c00000-f7c20000
eno1:1 Link encap: Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.11.200 Bcast:192.168.11.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:20 Memory:f7c00000-f7c20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:9856 errors:0 dropped:0 overruns:0 frame:0
TX packets:9856 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:731051 (731.0 KB) TX bytes:731051 (731.0 KB)
Output for ifconfig After i rebooted the server- I can't see the eno1:1 that i inserted in the /etc/network/interfaces file
eno1: Link encap: Ethernet HWaddr xx:xx:xx:xx:xx:xx
inet addr:192.168.11.199 Bcast:192.168.11.255 Mask:255.255.255.0
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:77 errors:0 dropped:0 overruns:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8760 (8.7 KB) TX bytes:10725 (10.7 KB)
Interrupt:20 Memory:f7c00000-f7c20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:190 errors:0 dropped:0 overruns:0 frame:0
TX packets:190 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:14760 (14.7 KB) TX bytes:14760 (14.7 KB)
Then i do ifup -v eno1:1 and then the eno1:1 comes back up when i do an ifconfig. I can also now search locally for 192.168.11.200 however it redirects to the other website on the server.
Output for service network start
failed to start network.service: Unit network.service not found.
Output for service network status
network.service
Loaded:not-found (Reason: No such file or directory)
Active: inactive (dead)
Outpu for ip route
default via 192.168.11.59 dev eno1 onlink
192.168.11.0/24 dev eno1 proto kernel scope link src 192.168.11.199
Afterwards I added a new entry in the firewall(using Mikrotik Firewall) for port 80 to allow traffic to HTTP for the domain. I also restarted the firewall to be safe.
Then i went to my domain provider and created an A record pointing my static ip to the new domain and also created the WWW record pointing my static ip to the new domain. Everything is good on this side.
I have googled around but can't seem to get this right. I went through many posts and still can't see my new domain from the browser.
I have done it this way when putting up the first website on the server and everything is working correctly.
If this is answered somewhere please guide me there.