user5008872
user5008872

Reputation:

Setting up multiple virtual hosts in Apache2

EDIT: I HAVE SINCE FIXED IT BY ALLOWING PORT 80 THROUGH UFW (sudo ufw allow 80)(sudo service ufw status verbose)

I've been fiddling with this for a while and can't figure it out, the issue I'm having is that the dev subdomain outputs files of the main server, you can find relevant info attached below.

I have changed my domain to abc.com, and changed the IP.

Yes, the config is enabled, and Apache has been restarted, but I'm still being served the file /var/www/abc.com/public/index.php rather than /var/www/dev.abc.com/public/index.php.

At this point, I've given up due to my lack of Linux + Apache knowledge.


Zone file:

$ORIGIN abc.com.
$TTL 1800
abc.com. IN SOA ns1.digitalocean.com. hostmaster.abc.com. 1467393676 10800 3600 604800 1800
abc.com. 1800 IN NS ada.ns.cloudflare.com.
abc.com. 1800 IN NS neil.ns.cloudflare.com.
abc.com. 1800 IN A XXX.XXX.XXX.XXX
www.abc.com. 1800 IN CNAME abc.com.
dev.abc.com. 1800 IN A XXX.XXX.XXX.XXX

/etc/hosts:

127.0.1.1 ubuntu-512mb-nyc2-01 ubuntu-512mb-nyc2-01
127.0.0.1 localhost
XXX.XXX.XXX.XXX abc.com
XXX.XXX.XXX.XXX www.abc.com
XXX.XXX.XXX.XXX dev.abc.com

::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

abc.com.conf:

NameVirtualHost XXX.XXX.XXX.XXX:80
ServerName abc.com

<VirtualHost XXX.XXX.XXX.XXX:80>
    ServerName  abc.com
    ServerAlias www.abc.com
    DocumentRoot /var/www/abc.com/public/
</VirtualHost>

<VirtualHost XXX.XXX.XXX.XXX:80>
    ServerName  dev.abc.com
    ServerAlias www.dev.abc.com
    DocumentRoot /var/www/dev.abc.com/public/
</VirtualHost>

Upvotes: 1

Views: 168

Answers (2)

AlexanderFC
AlexanderFC

Reputation: 36

Try removing 'ServerName abc.com' from below the 'NameVirtualHost' part; it can mess your config

Upvotes: 1

hyde
hyde

Reputation: 36

Have you checked the general error log? Maybe the reboot failed because of a misconfiguration?

Upvotes: 0

Related Questions