Popular Posts
-
US 01:36 15.04.2016Get short URL Marco Marsala seemingly lost all traces of his company, including the websites that he works with, b...
-
2017-08-22 Sports News of Tue, 22 Aug 20170 Tamale ready to host 2017 MTN FA Cup final - RFA Chairman File photo Mr. Abdoula...
-
July 17, 2017 by Sajal Chakraborty Learn about Amazon S3 (Simple Storage Service), creating a bucket in AWS S3 and then hosting stat...
-
Special Halloween Promo from SEMJar: Reliable and Affordable PBN Hosting. Available on October 28-31SEMJar, a SEO company renowned for its affordable services, invites every business owner to celebrate Halloween by getting reliable PBN ...
-
CHICAGO, June 20, 2016 /PRNewswire/ -- Paper Source, a Chicago-based specialty retailer and web store, will be hosting a warehouse sale o...
-
The Golden Globes were a strong night for "La La Land" and FX's "Atlanta," but first-time host Jim...
-
SANTA FE, NM --(Marketwired - March 26, 2016) - CrowdReviews.com, a provider of web hosting reviews and ratings, has released a statement...
-
Tweet Rackspace Hosting, Inc. (NYSE:RAX) – Analysts at Oppenheimer cut their Q3 2016 earnings per share ...
-
wedmfm.com is a wordpress.ORG software install on paid hosting, hosted by Bluehost, not by wordpress.COM. Contact your web host. You are...
-
WebSite X5 – Evolution is a powerful application which makes it easy to create top-quality responsive websites, even if you've no desi...
Blog Archive
- December (19)
- November (25)
- October (28)
- September (26)
- August (28)
- July (31)
- June (26)
- May (27)
- April (28)
- March (30)
- February (28)
- January (31)
- December (31)
- November (30)
- October (31)
- September (29)
- August (44)
- July (56)
- June (53)
- May (54)
- April (48)
- March (55)
- February (44)
- January (3)
- December (5)
- November (5)
- October (26)
- September (25)
- August (29)
- July (26)
- June (18)
- September (1)
About Me
Total Pageviews
How to host multiple websites on Apache2
Image: Jack Wallen
If you're a Linux system administrator, chances are you've worked with Apache. And if you've done enough Apache configuration, you've most likely set up virtual hosts. But if you're finally migrating away from your old Apache-powered web platform and onto Apache2 (the version of Apache shipped with the likes of Ubuntu Server), you'll need to change your way of thinking.
I'll walk you through the process of hosting multiple websites (aka virtual hosts) on an Apache2-based system (in this case Ubuntu 16.04). Believe it or not, it's simple...you just have to know what to configure and where to configure it.I assume you already have Apache installed and, if you point your browser to the server IP (or domain), either the Apache2 welcome page or your company site will appear. Let's add yet another site to your Apache2 server.
sites-availableWith Apache2, all virtual hosts are configured in individual files with /etc/apache2/sites-available. Each file will end in .conf and contain all of the details for the host. An example .conf file will look like:
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
What you see above is the sites-available file for Nextcloud—you could have multiple instances of Nextcloud on that server. Say you want, for whatever reason, Nextcloud and Nextcloud2—you could create a second sites-available .conf file for a second Nextcloud instance. Name that file nextcloud2.conf with the following contents:
Alias /nextcloud2 "/var/www/nextcloud2/"
<Directory /var/www/nextcloud2/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud2
SetEnv HTTP_HOME /var/www/nextcloud2
</Directory>
Note: In order for this example to work, Nextcould would also have to be installed on the server for each instance.
sites-enabledThe interesting thing about Apache2 is that you can create as many .conf files in /etc/apache2/sites-available as you want. But until those configuration files are enabled, Apache2 won't know about them. In order to enable those configuration files, you create the .conf file in sites-available and then use a simple command.
Say, for instance, we're setting up a test environment on our Apache2 server. We've created the test.conf file in /etc/apache2/sites-available with the contents:
Alias /test "/var/www/test/"
<Directory /var/www/test/>
Options +FollowSymlinks
AllowOverride All
SetEnv HOME /var/www/test
SetEnv HTTP_HOME /var/www/test
</Directory>
Once that file is in place, all we have to do is issue the command:
sudo a2ensite test.conf
The above command will copy the /etc/apache2/sites-available/test.conf file to /etc/apache2/sites-enabled and make Apache2 aware of the new host. Restart Apache2 with the command:
sudo service apache2 reload
Your test site is now available to use.
CongratulationsYou've enabled a new website on your Apache2 server. Although this is very basic information, it will allow you to run multiple hosts on a single Apache2 server. Note: It is important that you understand the ins and outs of the Apache2 .conf files; my very basic examples are only meant to illustrate the process.
Setting up multiple hosts on Apache2 is quite different than Apache, but once you get used to the system, it makes perfect sense. Besides, if you're working with a Linux server that makes use of Apache2, you don't have a choice.
Also seeSource: How to host multiple websites on Apache2
0 comments:
Post a Comment