Summer Sale! All accounts are 50% off this week.

ssquare's avatar

Trying to host laravel on subdomain on ubuntu vps, but subdomain loading website from main domain

So far, this is what I have done:

  1. Added A records:
Type  name  priority   content          ttl
A	  api	0	       123.456.789.000	14400
  1. set up project using git on /var/www/project

  2. On etc/apache2/sites-available hit sudo nano api.domain.link.conf and paste following code on it:

<VirtualHost *:80>

    ServerName api.domain.link
    ServerAlias www.api.domain.link
    ServerAdmin [email protected]

    DocumentRoot /var/www/project/public
    <Directory /var/www/project/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
  1. sudo a2ensite api.domain.link

  2. sudo systemctl reload apache2

sudo apachectl configtest 
 (Syntax Ok)
  1. sudo systemctl restart apache2

Now, when I hit api.domain.link its loading domain.link. I want to load var/www/project/public on here

0 likes
4 replies
Sinnbeck's avatar

Can you show the conf file for the main site?

kitchh's avatar

/etc/apache2/sites-enabled - did you add the softlink?

Please or to participate in this conversation.