How do I configure subdomains on linode on apache?

I've been trying for quite a while to configure subdomains on linode. But as a newbie I'm not fully sure what do to. Here are 2 sources I was using:

http://www.joabj.com/Writing/Tech/Tuts/Apache/Apache-Subdomains.html

https://matthewboyd123.medium.com/configuring-subdomains-apache-server-61d76a0f6cd1

But I'm still not getting it right.

The subdomain I'm experimenting with is: jan

In my linode dashboard, I tried adding a CNAME record for my subdomain. And that did not seem to help. So I deleted it and tried an A Record with the same name.

Here's what I did with my apache conf file:
<virtualhost *:80="">
# Admin email, Server Name (domain name), and any aliases
ServerName mynews.info
ServerAlias www.mynews.info</virtualhost>

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/mynews
# Log file locations
LogLevel warn
ErrorLog /var/log/apache2/error_mynews.log
CustomLog /var/log/apache2/access_mynews.log combined

domain: jan.mynews.info

public: /var/www/html/jan/

<virtualhost *:80="">
# Admin email, Server Name (domain name), and any aliases
ServerName jan.mynews.info
ServerAlias www.jan.mynews.info</virtualhost>

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/jan
# Log file locations
LogLevel warn
ErrorLog /var/log/apache2/error_mynews.log
CustomLog /var/log/apache2/access_mynews.log combined

I'm stumped. Can anyone guide me?

5 Replies

You need to stop using whatever HTML editor you're using to edit apache2(8) configurations. apache2(8) configuration directives are not (repeat, NOT!) HTML tags.

<virtualhost *:80="">
   # Admin email, Server Name (domain name), and any aliases
   ServerName mynews.info
   ServerAlias www.mynews.info
</virtualhost>

-- sw

Yeah, like @stevewi mentioned. Your text editor is adding extra characters which at the least is causing some of the errors.

I use VIM

Hi, I use nano on the command line to edit. Thanks for the answer.

I'm reusing old .conf files that were probably edited in HTML.

I'm stumped. Can anyone guide me?

Beyond your incorrect apache2(8) configuration, it's hard to see what you are trying to accomplish because of the format of your OP.

This board allows you to format things with Markdown. Some of the characters in your your message are being interpreted as Markdown control characters and that messes up the message even more.

See the Tips: section at the bottom left of this page… Also, use the Preview button above to verify the format is correct and conveys what you want.

I'd be more than willing to help you out if I understood better what you were trying to do. The format of your OP makes that nearly impossible.

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct