0

I'm a web programmer that has finally been tasked with setting up a development server for in house development and testing. I'm a novice when it comes to setting up a LAMP server. I've only ever managed to do the default LAMP stack with "tasksel", never managed to get multiple domains working properly.

What I would like to know is, is it possible to drop a single config file for a single domain/subdomain in a directory in order to configure it? I have a feeling this is how you use the directory /sites-available/ right?

Any tips in the right direction are greatly appreciated.

1 Answer 1

1

Yes, that is indeed how multiple subdomains are managed in Apache. You created a configuration in sites-available, and then enable them using the a2ensite command. For example, I have a local Ubuntu mirror and a repository set up on the same server: mirror (saved as /etc/apache2/sites-available/default.conf)and repo (saved as /etc/apache2/sites-available/repo.conf. Then I enable them thus (sudo or root needed):

a2ensite default
a2ensite repo
service apache2 reload

With proper DNS configuration, now repo.fqdn and mirror.fqdn, while resolving to the same IP, open the correct sites.

4
  • Would you mind posting the contents of your default.conf for me to see how you did it? Remove any personal information of course
    – Wh33t
    Aug 27, 2014 at 19:07
  • 1
    @Wh33t I have posted both configuration files. There are links above.
    – muru
    Aug 27, 2014 at 20:33
  • Gah, for some reason this isn't working. Here is my dev.conf which I've created in /etc/apache2/sites-enabled <VirtualHost 192.168.0.2> ServerName dev.server ServerAlias server DocumentRoot /var/www/html/subs/dev </VirtualHost> It appears to add correctly using a2ensite dev and I've reloaded the service yet it still brings me to the default directory when viewed over the web. Any ideas?
    – Wh33t
    Aug 28, 2014 at 20:05
  • I think I've got it now. It appears as though service apache2 reload requires SUDO in front of it. I also manually installed apache, php and mysql without using tasksel and that might have made some difference as well.
    – Wh33t
    Aug 28, 2014 at 21:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .