Host Multiple Domains on One Server using Digital Ocean. Setup Virtual Hosts and SSL. | John D. | Skillshare

Host Multiple Domains on One Server using Digital Ocean. Setup Virtual Hosts and SSL.

John D., Start learning & acquire the skills you need!

Host Multiple Domains on One Server using Digital Ocean. Setup Virtual Hosts and SSL.

John D., Start learning & acquire the skills you need!

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
16 Lessons (1h 15m)
    • 1. Introduction

    • 2. Learning Objectives

    • 3. Deploying a Server on Digital Ocean

    • 4. Creating and Attaching a Floating IP

    • 5. Intro to Terminal and Root user Authentication

    • 6. Apache Installation and Testing

    • 7. Installing MySQL Database Management System

    • 8. Installing & Testing PHP

    • 9. Installing PhpMyAdmin for Database Administration

    • 10. Introduction to Virtual Hosts

    • 11. Directory Structure, Permissions and Test Files

    • 12. Configuring Virtual Host Files and Directives

    • 13. Name Server Configuration

    • 14. DNS Zone File Configuration & Testing

    • 15. Installing SSL for each Domain using Let's Encrypt

    • 16. Summary & Next Steps

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this exciting new course, we show you how to host multiple domain names on a single Digital Ocean droplet. We will show you step-by-step how to configure a droplet with LAMP Stack on Ubuntu 18.04. This includes deploying a droplet, installing Ubuntu and all the components included in LAMP Stack including Apache, MySQL, PHP and PhpMyAdmin.

We also explore an exciting new feature offered by Digital Ocean, called "Floating IP's" which allow you to transfer IP's easily between multiple droplets.

After you understand the foundations of server configuration, we get into configuring Name Servers, DNS Zone Files and Virtual Hosts to host multiple domains from a single Virtual Server. You will have a thorough understanding of setting file permissions and developing an organized directory structure for all your websites.

We also show you how to configure an SSL certificate for each and every website that you host on your virtual server. For this part of the course we will be using Let’s Encrypt. Let’s Encrypt is a certificate authority that offers free SSL certificates, which are extremely simple to install and very secure.

You are welcome to use any hosting provider for this course, as the concepts can be easily implemented on any Virtual Server configured with the Ubuntu distribution.

Meet Your Teacher

Teacher Profile Image

John D.

Start learning & acquire the skills you need!


Our Mission:

To facilitate a comprehensive online learning environment for students.

About us:

YouAccel is a leading provider in online training and job search solutions.

We provide a streamlined approach to learning and acquiring the skills you need to gain employment in your desired field of work. We offer a broad range of courses in many subjects.

Courses are taught by certified, renowned experts with several years of work experience. You can be confident that the methods instructed in our courses are designed to thoroughly enhance your knowledge and skill set.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Introduction: hello and welcome. In this exciting new course, we show you how to host multiple domain names on a single virtual server. We'll show you step by step, how to configure a droplet on digital ocean with lamp stack for you bun to 18.4 This includes installing you want to and all the components included in lamp stack, including Upashi, my SQL, PHP and PHP. My men. We also explore an exciting new feature offered by digital ocean called floating eyepiece, which allow you to transfer eyepiece easily between multiple virtual servers. After you understand the foundations of server configuration, we get into configuring name servers, DNS, zone files and virtual hosts to host multiple domain names from a single virtual server. After this course, you have a thorough understanding of setting file permissions and developing an organized directory structure for all your websites. We also show you how to configure an SSL certificate for each and every website that you host on your virtual server. For this part of the course will be using Let's encrypt. Let's encrypt is a certificate authority that offers free SSL certificates which are extremely simple to install and very secure Although we use digital ocean, you're welcome to use any hosting provider for this course, as the concepts can easily be implemented on any virtual server configured with the U bun to distribution. So if you're as excited as we are about this course, go ahead and sign up and let's get started. 2. Learning Objectives: hello and welcome. Glad you could join us for our new course today. We're going to set up in host multiple websites on a single digital ocean droplet using virtual hosts. Although we're using digital ocean, you could follow along with any cloud hosting provider of your choice. In case you're wondering why you would want to take this class well, there's many reasons primarily you may want to cut costs on your own hosting fees if you have multiple websites. Many administrators create separate servers for each website, and this can quickly become very costly. By hosting multiple websites on one resource, you eliminate the need for so many different servers. Another reason is that you want to start your own hosting company. Were you charge clients a fee for hosting and administering their website. Although this course is only an introduction, it will give you a good starting point for branching out into offering. Hosting services in this class will be configuring our server using lab stack on your boon to 18.4 This is the latest version as of today's date, but the concepts we cover can be applied to any version, including or higher than you want to 14.4 Keep in mind if you're using an older version of you want to, you no longer receive security updates, so it would be a great time to update. This course requires some basic knowledge of executing commands through terminal. If you're on a Windows machine, you can use putty. If you need further information on how to use these tools and run basic commands on a server, you can take our Web development. Masterclass, however, will be running the commands directly in this class, so you can easily just follow along as well. In this course, you learn to configure name servers, DNS, zone files and virtual hosts in order to serve multiple websites on a single server. Each of our domains will have a separate SSL certificate as well. The SSL certificate authority will be using his Let's encrypt. This is a great resource if you're looking for a quick, free and simple way to secure your Web pages. Another point worth mentioning is will be doing all are set up and configuring. Using a root user account is explained in our Web development masterclass. It's always a good practice to disable the root user account once set up is complete and create a new user to keep your server secure. Since we already covered this in another course, we won't be going over it again. Setting up multiple domains on one virtual server is fairly easy. Keep in mind it needs to be done carefully from the beginning, so you don't run into issues later on. That can be more challenging to resolve. For this class, you lead the following items. A Mac or Linux system with terminal or any command line. Consul of your choice. If you're on a Windows machine, you need to download putty. Ssh Client. You'll need the domain names for each site that you want a host on your digital ocean. Drop it. This means you must have the domain names registered and accessible. If you do not have domain names, you will not be able to install the SSL certificate or test your configuration. You'll need access to the name server configuration from your domain name. Registrar. You also need a digital ocean account or an account with any virtual cloud hosting provider of your choice 3. Deploying a Server on Digital Ocean: The first step in this process is to log into your digital ocean account. If you don't have an account, click the sign a button. You'll be prompted to enter the email address and the password you'd like to use. Once you've created an account, you have to enter some basic payment details, and then you'll be able to use digital ocean to create servers. Since I already have an account, I'm going to go ahead and click the log in button. I'll go ahead and enter my log in credentials. We're now on the digital ocean dashboard. So here, under the resources tab, you can see the different droplets that you have and also the different domains that are attached to this project. On the left hand side, you can see the different projects that are in this digital ocean account a project. You can think of it as a folder that contains different droplets in different domains, different settings that pertain to different websites. So since we're gonna be working on a completely new project on, we know hope, go ahead and click the new project button here. So we're now prompted to enter a name for the project. I'll go ahead and call it Main server. Now you can call your project anything you like, because this server's gonna be hosting multiple domains. I gave it a more generic name. If your server was gonna be dedicated for one website, you could enter a name that's more relevant to that website. It's not required that you add a description, but it is required that you select a purpose, so I'll go ahead and select development. Now it's asking if we want to move any existing resources to our main server. We don't want to do this, so I'm going to go ahead and click Skip for now on the left menu, you can see that the main server project is now available. So now back on this main page, we can go ahead and create our droplet to do so quick to create droplet button. In this section, we can select the type of distribution we want to configure on our droplet. Since we're gonna be working with you bun to select you bun to 18.4 64 bit. If it's not the default here, you can select it from the menu the next thing will need to do is select a size for the droplet. Now I'm going to select the smallest size of one gigabyte memory, one CPU, 25 gigabytes of SSD disk space and one terabyte transfer per month. If you know that you're gonna be using this server for something much more extensive than just learning purposes, then you want to select a higher configuration, and that configuration will depend entirely on your needs. So for now, I'm just gonna select the first option. We're going to scroll down the page, and the next thing will need to do here is select a data region. If you're gonna be using this Web server for serving Web pages to your customers, you want to select a region closest to your customers. This will ensure your website loads as fast as possible when visitors access your site. But again, this is just for demonstration purposes. So I'm going to go ahead and select New York no scrolling down. The next thing will need to do here is choose a host name for this server. So again, because the server will be hosting multiple sites, I can give it a generic name call it main server, just like we did for the project. Now go ahead and click Create. You'll see the blue status bar appears, and that indicates the progress on the deployment of this server, and it normally doesn't take more than one or two minutes. So the server has now been created, and you can see that an I P. Has been assigned to the server by default. Digital Ocean has also emailed you your password for the server. So you want to make sure that you logged into your email and make sure that that email is there because we'll be using that password shortly. This is known as your route administrative password. 4. Creating and Attaching a Floating IP: with our server created, you can see the I P address here. One point worth mentioning is that this I p is permanently attached to this droplet. It cannot be reassigned. Toa another droplet. This year, Digital Ocean introduced a new feature called Floating Eyepiece, and this allows us to create an I P and attach it to any droplet of our choice at any time . This feature is very similar to the Amazon Web services dynamic I p feature. If you're using Amazon Web services, you can do the same thing. This feature is extremely useful toe have for many purposes. For example, say you build an application, and at a specific date you create a snapshot of it. A snapshot in digital ocean is like a disk image that can easily be reinstalled at any time on any other server. Now say you develop this application and something goes horribly wrong, and you need to revert back to the snapshot at a previous date. Typically, changing an I P address for your server can be a very big hassle. It's something you generally want to avoid, so floating eyepiece make it very simple to deploy a new server load your snapshot and easily assign your i p to the new server. Apart from this example, there are many other benefits of using floating or transferrable eyepiece. And for this reason, let's go ahead and attach a floating i p to this droplet click over here where it says, start using floating eyepiece. Now you want to click in this menu here, you want to select the server that you just deployed in this case, we deployed main server on the right here. Press the assigned floating I p one Just give that a second or two and you can see that the floating I p was successfully added to the server. We just created so perfect. That's all there really is to it. Now that the i p has been assigned, you can administer your server using this floating I p rather than the permanent I p that we'd seen earlier. Just his aside. No, it is always a good practice to set up your floating. I pee in the beginning. This gives you the flexibility of transferring the I p at a later date should you need to 5. Intro to Terminal and Root user Authentication: with our server created, we can now go ahead and set it up. If you're on a Mac system, you need to open. Terminal terminal can be used to execute command lines to your server. If you're on a window system, you can use putty. You're not limited to these tools. Feel free to use any command consuls you feel more comfortable using. If you are using terminal, the first thing you'll need to do is connect your server to do so. Typing. Ssh room. Uh, and then you're going to need your i p address. So remember, we're using the floating I P. So I'm gonna go ahead and copy that I'm gonna paste it. Press enter. You'll be prompted with a security message. Just typing. Yes, and press enter. No, it's asking for your password. So, as I explained earlier, you would have received an email from Digital Ocean that looks something like this. It just confirms that your droplet is set up and ready to go, and then it gives you your access credentials. So in this case, this is what your password is gonna look like. Of course, it would be something different, but that's the floor mat and your user name is route. We are gonna be using the root account to set all this up. So I'm gonna copy the password and paste, and then press enter so right away it's gonna ask you to change your existing password, so enter your current password so I'm going to right click and hit paste again. Press enter, and I'm gonna enter a new password that secure but also easier to remember. Now you need to read type your new password just to confirm. So now you can see where logged in as root user. And you can also see the server name that we designed when we initially deployed the server in Digital Ocean. 6. Apache Installation and Testing: we can now go ahead and set up our Web server. The first step is to install Upashi. If you're new to Web server configuration. Upashi is an http server that allows our Web page visitors to establish a connection to our server and download the Web page content. Remember when anyone accesses your site there, essentially downloading the page in order to view it through their browser. To start the Upashi installation will need to update the local package index. The package index is an index of files that are available for update as soon as you launch your server. You want to run this command typing apt update so you can see here that it says four packages could be upgraded. The next command will want to run is to install Upashi to do so. Typing apt installed Upashi, too. Just make sure you don't make any typos in the commands. Otherwise they won't work properly. We're just prompted with a question. It says After this operation, 6978 kilobytes of additional disk space will be used. Do you want to continue? Will enter why and press enter. So this is the progress bar here, you can see where 75% and it typically shouldn't take more than one or two minutes for the entire process to be complete. Okay, so there we go, Upashi to has now been installed. And we contest it by pulling up the default Upashi page in our web browser. So what you want to do here is take your I p copy it, paste it into your address bar and press enter and you should see the default. Upashi, too. A page over here. So as long as you see this page, then you know that it's working property. 7. Installing MySQL Database Management System: Now that we have Upashi installed, we can go ahead and install essential services, including my SQL, PHP and PHP by eight men. We'll start with my SQL. My SQL is a database management system. It organizes and provides access to databases where you can store information. A common example is storing customer information If you operate une commerce site to install my SQL type the following command. Now, if you're logged into the root account, you don't have to type in pseudo. But I'll just keep it there because I'm copying and pasting the command lines to save a bit of time. So Sudo Apt installed my SQL Dash server and press enter. Okay, So at the first prompt, which just indicates that it's going to take 162 megabytes of additional disk space, which were fined with typing why and press enter so again you'll see the Progress Bar appears, and it should go by fairly quickly. When the installation is complete, we can secure our my SQL installation. This is a good practice, and it just means getting rid of some of the dangerous default settings that could be a security risk to your database server. So to do so, type in the following command and press enter. So will now go through the various prompts to complete this installation. The 1st 1 is it's asking if we want to use the validate password Plug in. This could be used to enhance password security by default. So any time you want to set a password, it will force you to stick to a certain format for the password. A secure format. It's great to use this if you're comfortable with my SQL. Also, if you don't intend on using many plug ins, for example, WordPress or if you're gonna be installing PHP my admin, there can be certain things that conflict with this particular plug in. So for this purpose will go ahead and type in no and press enter. So now we'll have to enter a password for my SQL. This is to connect your database server. So again, just make sure that it's something secure, but something you can remember as well. If you pick a very complicated password, Do remember to write it down and stored somewhere safely, and I'll just go ahead and re enter it. Press enter. I'm gonna try that one more time. Okay, So the next prompt here is asking about anonymous users. It says, by default. My SQL installation has an anonymous user allowing anyone to log into my SQL without having to have a user account created for them. This is intended only for testing and to make the installation go a bit smoother. You should remove that. You should remove them before moving into a production environment. So even though we're just setting this up, the ultimate goal is to move into production. So we'll go ahead and select yes, to remove the anonymous user and press enter. Okay. The next thing is to do we want to disallow root, log and remotely. Typically, you only want to allow the local host toe log in his route. This is a This is a great practice for security. And so when you go ahead and select, yes, disallow root log in so remote users cannot log in his route and press enter by default. My astral comes with a database name test that anyone can access. This is also intended only for testing and should be removed before moving into a production environment. So again, we don't need this test database. I'll go ahead and type y and press enter. Okay, So the next step hears reloading the privilege tables and this will ensure that all the changes we just made take effect immediately. So it's like, why? And press enter? And there it is. We're all done with setting up my SQL. One last item that remains here is to change our authentication method that my SQL uses to authenticate the root user. Although the default authentication method does offer some additional security, it conflicts with other tools that we need to install later, such as PHP my UNMIN. So for this reason will need to switch our authentication method from off underscore socket to my SQL native password. And you understand how this works in just a second. This basically means we can use a regular password to authenticate. Now, to do this, you're gonna start by typing the following command. Okay, so now we've opened up my SQL. Now, let's go ahead and check which authentication method each of our mind Estoril user accounts uses to authenticate. To do that type in the following command compress enter the table that you see here does confirm that the root user does, in fact, connect with off socket to change. This will need to type of command. So go ahead and paste in the command, but there's a perimeter will need to change. So this is the command here. Okay, so we want to alter the authentication method for route at local host. We want to identify with my SQL native password. Now, you need to change over here where it says password. You need to type in the password you want to authenticate with. Okay, so I've entered the password I want to authenticate with, and I'm gonna go ahead and press enter. So you see this message query. Okay. And that tells you that the command was executed successfully. Now we'll need to run the Flush Privileges Command. And this tells the server to reload the grant tables and put your new changes into effect. So this is what the command is flush privileges and press enter. Now that we've completed these steps, let's confirm that the root user no longer authenticates using the off socket plug in. So type in the following command and press enter. We can confirm in this table that the root user now authenticates with my SQL native password and no longer with the off socket plug in. 8. Installing & Testing PHP: Now that we have my SQL installed, we can install PHP. PHP is a powerful, widely adopted programming language that allows you to serve Web content that is dynamic and interact with your users. With PHP integration, you can communicate with your my SQL databases to execute tasks such as inserting, updating or retrieving data. Before we begin installation, you need to exit my SQL so typing exit and press enter to start the installation process for PHP, type in the following command typing why it the prompt and press enter. So that's really all there is to it for installing PHP. For the changes to take effect will go ahead and restart our Upashi server by typing the following command and press enter. We can now go ahead and test our PHP configuration to make sure it's working properly. To do this will create a file called info dot PHP and place it in our default HTML directory. The file that will be creating contains a basic script that displays data about our PHP configuration so you can create this file by running the following command. So Nano is the text editor that we use Okay, the HTML directory That's the default directory that Upashi serves our Web content from. That will change when we create virtual hosts for multiple domains. But for now, that is the default directory. An info dot PHP is a file we're going to be creating, suppress, enter. And now we're in Nano text editor. So the next thing to do here, it's just paste in a bit of code into this file. So it's a bit of PHP code and this command here PHP info. That is what's going to display the the the information about PHP on our server when we load this page on our web browse. So after you've typed in this code, you need to save this file. And to do that, I'm gonna hold control down and press X. Now it's gonna ask me if I want to save the changes from the type and why, and I'm gonna press enter to write the changes to his file, and there we go. Okay, so now what we can do is open your browser again, type in slash info dot PHP and this is the file that should load as long as everything is working correctly. Okay, so it says the PHP version and a whole bunch of other information about your PHP configuration. Okay, One important point to mention here is you want to delete this file for your production server because it does contain a lot of information about your configuration that you wouldn't necessarily want. You wouldn't want this information in the wrong hands, so we'll go ahead and delete this file. So to do that, just type in the following command. It's the RM and then point to the file on our server. So what that will do is is it will remove it as soon as we execute it. So press enter. Now when I try to load that, it's no longer found. 9. Installing PhpMyAdmin for Database Administration: with Upashi, my SQL and PHP installed, we can go ahead and install PHP by admitting PHP. My admin is a very handy tool that could be used to interact with your my SQL databases through a graphical user interface. This makes administration of databases much easier than trying to do it through executing command lines before we install PHP. My admin. Let's go ahead and update our package index like we did earlier, although it's likely not necessary, since we just updated our package index. Pretty recently, it's a good practice to run the update command prior to installation of any major component . So typing act update and now type in the following command to get PHP mind hman press. Enter a type. Why, when prompted, press enter again. Here, you'll need to select your Web server. Make sure that you have Upashi to highlighted. Also, make sure you hit the space bar to make sure that Upashi to is, in fact checked, as you can see here. And once you've done that press OK, okay, so now you'll see a message. It says the PHP might mean package must have a database installed and configured before it can be used. If you're an advanced database administrator and know that you want to perform this configuration manually or if your database has already been installed and configured, you should refuse this option. It's all just move forward. We do want this installer to configure a database for PHP minded men, so make sure that you select yes and press enter. You now have to enter a my SQL application password for PHP. My admin. So again, just make sure it's something you can remember and something that is secure. The installation process automatically adds the PHP my admin configuration file into the following directory that you see on your screen. So all we need to do now is enabled the MBI string PHP extension by typing the following command. Okay, once you've entered that command, press enter and the last step here is to restart Upashi for the changes to be recognized. So typing this command and press enter to make sure that PHP my admin has been installed successfully, you can type PHP my Goodman after your I p and you should see the PHP mind men log in page appear so you can enter your user name is route. And the password is the password that you would configure during installation. Okay. And there it is. So this is the PHP mind men. Ah, user interface. Okay, all your databases air here on the left, and it's a great tool for administering your databases. If you do want a master PHP mind hman, We do have the whole section devoted to it in our web development masterclass. And that will show you how do administer databases work with different users, import export data and, ah, whole volume of other information. OK, but for now, we'll just hit the back button or it's probably a better practice. Tow law. Go. So this is the log out button right here, and it takes you back to the log in page, so I'm just going to go back to our default index page 10. Introduction to Virtual Hosts: before we continue, it's important to understand what we'll be doing in the next part of this course. We're now going to be setting up virtual hosts that allow multiple domains to be served from a single server to recap. So far, we've deployed a droplet installed Upashi, my SQL PHP and PHP minded men. So let's go ahead and get started on working with virtual hosts. It's important to understand that by default, Upashi identifies the HTML directory in the www folder as the root folder for our Web pages . This means when someone visits our primary website domain, Upashi will load the index dot html file, located in the HTML directory. Now when I say primary domain, what I mean is, if you're only hosting one domain on your Web server, if you're holed hosting multiple domain names, then you don't have a primary domain. Since we will be working with multiple domains, each domain will need to point to its own unique directory. So, for example, x y z dot com. We'll need to load the default index page from the x y z dot com folder that we create. Okay, so here is a sample of the directory structure we're gonna be creating in our www folder. We're going to create a directory for each domain name. So, for example, if you had two domains, this is exactly what your directory structure would look like. The domain name as the folder name. And then inside that folder, we would have another folder called HTML, and inside the HTML folder would be all our website files. Okay, And that's the same if you had a second domain, that's exactly what it would look like except that the domain name would be different. So instead of x y z dot com, your second domain can be abc dot com. So it's fairly straightforward, and you can have 10 20 however many of these as you needed to have. So if you're running a small hosting company, you might have 100 clients. Well, you can set up 100 directories, each with a different domain name, so this is the first step before we actually go on to creating virtual hosts, and we'll see you in the next lecture 11. Directory Structure, Permissions and Test Files: before we can go ahead and configure our virtual host file, we'll need to make a directory for each domain that we want a host on the server. To do so, we'll use the following command. This is the Make directory Command, and we'll need to replace example dot com with our first domain. Once you've done that, go ahead and press enter. Now we'll need to change the permissions of this directory as well. But we'll do that in a moment Before we do that. Let's go ahead and make the directory for our second domain as well. So that way, at least we have our folders created and press enter. So one easy way to administer folders rather than typing in command lines and doing it that way is if you haven't ftp agent there. So, for example, file zilla or anything like that, it's a lot easier to just connect to your Web server and administer filed in folders that way. So I'm gonna go ahead and launch file Zilla, and I'm going to go into my site manager now. I already have this server configured here is test. If you don't just quick new site well you're gonna select the s ftp method and make sure you don't select FTP select sftp for the host name. You're going to need your floating i p address. So go back to Digital Ocean and just copy this I p address here and enter your I p address next to the host label for log on type Select Normal. You're gonna log in his route user and type in your password that you selected when you initially deployed your droplet and then click connect. Okay, you're gonna receive a message is saying this. Servers host, He is unknown. Just go ahead and click, OK, now you're gonna scroll up, so just double click this full they're here. And once you've gone up one directory, you're going to go in the VAR directory and then in the www directory. So, as you can see, we have the two folders we just created. This is the first domain in the second domain and what we're gonna do is we're going to reset the permissions for both of these domains. So to do that right, click on each domain and go to file permissions, make sure that it's 755 in this case it is. So, uh, there's nothing left to change their and the 2nd 1 should be the same. 755 Ok, that's perfect. Now what we're gonna do is create an HTML folder inside each one of these directories. So I'm gonna click on this first directory and I'm going to right click and select, create directory type in HTML. And just check to make sure that the file permissions air correct stepping 755 and press. OK, now go up going to the second domain directory and create a folder called HTML again and again set the file permissions. Okay, So perfect. We now have our two domains. If you have other domains you'd like to add, you can go ahead and repeat that step for each domain that you'd like hosted on the server . Now, if you do have a number of domains here, you're probably going to just want to set the permissions for the entire www directory For now and then, as you build your Web content, you can always set up individual file and folder permissions separately. But if you're dealing with a lot of domain, just right, click on your www folder, Go to file permissions and what you can do is place a check mark in this boxier re curse into subdirectories. So what will happen? There is every single folder inside the www directory will also have the same permissions that you establish here. So go ahead and click, OK? And so that Yeah, that's a lot. Ah, a lot faster if you're dealing with many different domains. Okay, so here we are, back in terminal, and the next thing we need to do here is create the default index dot html file that will load when somebody visits each domain. So each domain would need its own separate index dot html file, which is relevant to that domain. Okay, so we can go ahead and create this file in Nano text editor, so just paste in the following command here, make sure that you replace example dot com with your domain name. We'll do one domain at the time so you can start with the 1st 1 and then move on to the second and press enter. Now, inside this file, you need to paste in the following code. So it's just a basic html page and the title for the first page is welcome to domain one. Now you can replace domain one with your actual domain name and in the body we're just gonna have success. Domain one is configured correctly. You want to save this file by pressing control? X take why, if the prompt and press enter Now, let's go ahead and create the index dot html file for our second domain. So use Now. I know again, all you need to do is change your domain name in the command to your second domain and press enter. Be careful not to ah, be careful to avoid any typos. Any spelling mistakes in the domain names or folder names will cause issues later on. So breast center and just paste again. And this time I'm gonna put welcome to domain to and success domain to is configured correctly. Now, save this file, enter okay. And we'll see you in the next lecture 12. Configuring Virtual Host Files and Directives: Welcome back to recap. We've now set up two folders for each of our domains. We've also created a default HTML file that will load when somebody visits each domain. What we need to do now is set up the new virtual host files for each domain. In order for all of this to work this way, each domain will point to its unique directory and the Web pages contained within it. The default configuration directive for Upashi is located at this path. The default dot com file instructs Upashi, which directory to serve content from when the server is only hosting one domain. We need to make the virtual host file for our first domain, since this server will host multiple domains after this will create a virtual host fall for our second and third and fourth and however many domains you have. So to do this, start by making a new file by typing the following command. Replace example dot com with your domain name. Okay, Once you've done that, go ahead and press enter once you're in 90 Text Editor Detective Following text. There's a few perimeters which you'll need to change to reflect your domain name. So the 1st 1 is the email address. The second is a server name. And the server name is just your domain name without the www prefix. The server Alias is your domain name with the W W W prefix. And once you've confirmed that everything is correct, go ahead and save the file. So, Control X, why it the prompt and enter? So once you finish with those modifications, you need to enable this file using the following command. Okay? I accidentally executed that before I did made the changes, so I just take that in again. Make sure you replace example dot com with your domain name and press enter. Once you've done that, you'll see the message enabling site displayed. And it'll also instruct you to restart Upashi in order for you to activate this new configuration. So go ahead and read. Reload, Upashi. After you typed in this command, press enter. So now that we have are our first virtual host file created and enabled, we can go ahead and create the 2nd 1 The easiest way to do this is by duplicating the 1st 1 renaming it and making whatever changes we need to make in the new duplicated file. So to do that, you're gonna take the following command. Sudo cp just means copy, and then you're instructing on which file you want copied. So I'm gonna copy the file that we already configured, and this is gonna be the new duplicated file that's created. We want the name of this file to be the second Don't domain name and press enter. Let's go ahead and open this file. The second foul we just created. We're opening it in Nano, and we'll have to change the parameters this time to match the second domain name again . Make sure you haven't made any spelling mistakes or typos. And once you're okay with the changes, save the file type y and press enter. Now let's go ahead and enable this configuration that we just created a swell. So we're gonna use that same ah command once again sudo a to e and s I t this time we're doing this second domain and press enter. Okay, so now that we have the two virtual host files created for the two domain names, we're gonna disable the default configuration file. So type in the following and press. Enter. Now we'll need to reload Upashi for all these changes to take effect. Perfect. We've now created the two virtual host files for each of our two domains. And we've enabled them as well. The next step in this process will be to configure our name servers with our domain name Registrar. So we'll see you in the next lesson. 13. Name Server Configuration: We're now at the stage where we can configure our domain name servers and DNS zone file name servers will instruct your domain registrar on which hosting company your domain should point to the DNS zone file, on the other hand, is configured on your hosting companies in mint panel. In this case, Digital Ocean. The Zone file contains information on which Web server each domain should point to. By now, you likely get the idea after we configure the zone file for each domain, our Web server delivers the Web pages based on instructions from the virtual host file we created for each domain. I'll now go ahead and change my domain name servers so they point to Digital Ocean. Since my domains air registered with godaddy dot com, I've pulled up their web page here. Now I'm gonna go ahead and sign in. Okay, Next to now next to my domain, I'm going to click the DNS button, and when you scroll down, you'll see the heading name servers. This is the area you want to change. You want to make sure that your name servers are pointing to digital ocean right now, my name servers are pointing to Amazon Web services. So go ahead and change. That and the name service for digital ocean are as follows. Ennis one dot digital ocean dot com and as to and s three dot digital ocean dot com. And we don't need the last one. So I'm just gonna do eat it and press save. You need to do this for each domain that you'd like to host on your digital ocean droplet. So if you have two or three year, however many domains you'll be using, you need to log into your registrar and change the name servers. Make sure they're pointing to digital ocean. Now, if you're using a different virtual host host provider such as Amazon or ah, Microsoft, it doesn't matter. Just make sure that you put in their corresponding name servers. We need to head back to Digital Ocean 14. DNS Zone File Configuration & Testing: Now that we have our name servers pointing to digital ocean, we need to configure our DNS zone file so that our domain points to the correct server to do so. If you haven't already go back to the digital Ocean admin panel and you're gonna click on the networking link under the heading ad domain, you're gonna type in the first domain name you'd like to host on your droplet. Make sure from the menu over here you select a server you just created and then click add Do me. All we need to do now is at two a records that point to the I p address of our server one a record will be for our domain name without the www prefix. The second will include the www prefix. So just go ahead and make sure you have a selected here. So typing an at sign here and on the right side here you're going to select the floating I p. We created and hit create record. Now we're gonna create another a record, So type in www and select the floating I p again and create record. Now a separate DNS record is required for both domains. We finished this first domain. So let's go ahead and do this second domain the same way. So go back to networking. Typing the second domain. Select a server we just created from the menu and hit ad domain. Create your first A record tipping the at sign again. Select the floating I P and create record. Now create the www record. It'll direct to the floating I p and create record. Perfect. So now we have our to DNS zone falls created for each of our domains. So with our name, servers and DNS records now configured, we can test to make sure that everything is working. Keep in mind that any time you make changes to name servers, it can take up to 48 hours for them to propagate. So if it doesn't work right away, don't be alarmed. Just wait a day or so and try. Try again. You know, if it doesn't work from that point forward, then you know that there's probably some issue going on in your configuration somewhere. Okay, so when you go ahead and test the first domain name, okay, so you can see that it says this site can be reached. That means that the changes have not propagated in the DNS system. Yet. There is a way to bypass this just to make sure that it is in fact working. And I'll show you that in just a second. But before I do that, let me test the second domain. And this time you can see that this domain is working correctly. Okay, so the 2nd 1 is working. If you remember, we created this html page and placed it into the HTML folder of our second domain. And so this one is working. The 1st 1 is still propagating. One way to bypass the DNS from propagating is to try to access your website through a proxy that has likely never visited your website before. I have been to the first domain earlier this week, so that page or the I p associated with that page is likely still cached with my Internet service provider or some local DNS service somewhere in my area. So what I'm gonna do is I'm gonna go to a free proxy service. So if you just go to google dot com and type in free Web proxy and let's go ahead and enter the domain through this proxy because nobody from the Netherlands is likely visited this domain name. It's not gonna pull up a cashed I p address. It's going to try to resolve the i P address using the new information the new name servers that we confirm that we configured with our domain name Registrar. So hopefully this isn't too confusing for you. Um, a simpler solution is to just wait a day or so, and it will start working for you. But if you want to, you know, sometimes you don't have that luxury of waiting or you can just test it on a proxy, and as long as it works on the proxy, then you know for sure within a matter of hours, it's going to start working in your area and just about everywhere where DNS systems are constantly rebuilding their the I P addresses attached to each domain. Okay, so you can see that through the proxy. It did pull up the right page, so that means it connected to the correct I P address based on the name servers we'd set up with our domain registrar. So that means our Web server is now pulling up separate pages in separate directories for each domain name that we're hosting on the server. And so we've accomplished the first part of what we set out to do. In the next lesson, we're going to be installing separate SSL certificates for each of these domains. 15. Installing SSL for each Domain using Let's Encrypt: in this lesson will be securing each of our domains with SSL using Let's encrypt Let's encrypt is a free, easy to use SSL certificate that can be installed within a few simple steps back in terminal. We need to install this certain bought software on our server. To do so. Type in the following command. Once you finish typing in this command press, enter press enter to continue now install certain thoughts Upashi package using the app method. So typing this command and press enter typing Why it the prompt In order for a certain bought toe automatically configure SSL. It needs to be able to find the correct virtual host file for each domain in the Upashi configuration. Since we already set up our virtual host directives, we can go ahead and obtain our SSL certificates. There's actually two ways of doing this. Typically, if you already have your domains configured, you can register a certificate for all the domains at once, and the syntax for this would be assed follows. As you can see, we have each domain name, including its www prefix in the command line. So each domain name is precedes the Dash D flag And so if you had five or 10 or however many domains, you could plug them all in it once over here to save time. However, most of the time you'll be adding certificates, period as you register additional domains or take on more clients in the case where you're running a hosting company. So for this reason, will register eat certificates separately, as you would normally do in the course of business. So let's go ahead and start with our first domain. You're gonna type in this command here. You're gonna replace example dot com with your domain with your first domain name. Once you finish that double, check that you've entered the correct domain name. You don't want to make any mistakes here and go ahead and press enter. Now it's gonna ask you for an email address just for administrative purposes so you can go ahead and enter that it you have to agree to the terms of service. So type in a and press enter. Now it's asking if we'd be willing to share the email address with the Electronic Frontier Foundation. I'll just go ahead and select. No, this is an important question. It's asking Do you want to redirect all requests to the https version of your website? Now, typically, you do want to do this if somebody types in www dot your domain dot com or text in your domain without the w w prefix. Whatever the case may be, we want all requests to redirect to the H T. T. P s version of our website. If for any reason you don't want that, then you're gonna enter one here and press enter. But if you do want that, you're gonna type in two and you're gonna press center. Okay, So perfect. As soon as you finish that, you'll see the congratulations. Method. Your certificate and chain have been saved at on, and then it gives you the directory and file name in a second. We will load our domain on our in our Web browser again just to make sure that it is secure . Make sure that the SSL lock is present. But before we do that, let's go ahead and create the certificate for our second domain as well. So again, you're going to use the same command and press enter. Since we've already configured the administrative email for our server. We don't. It's not gonna prompt us for that again. All we have to do is decide whether we want to redirect all traffic for this domain to the https version of the site. So once again, we do so when enter to impress enter. Okay, Perfect. So when we now have both our certificates installed for each separate domain and all we have to do is test to make sure that it's working. Since we're accessing the first domain through a proxy service the secure message here that is not relevant to our SSL certificate for the first domain, we will have to wait till the DNs propagates in order for us to view our SSL certificate over here in the secure message area. But since our second domain works, we can certainly test that out. And you can see over here that it is labeled secure, and that means that our certificate is valid and you can see here that it's issued by the let's encrypt authority. So everything is in order. So I just tried the first domain again in case it has propagated. No. Perfect. Okay, so now it has propagated. So it took probably around 10 minutes. Okay, so sometimes it's very quick and you can see that the first domain is secure as well. Here's a certificate again issued by Let's Encrypt authority. 16. Summary & Next Steps: in this course, you learn how to deploy a droplet on digital ocean with you one, too. Create floating eyepiece. Set up lamp stack on your bun, too. You also learn to create the directory structure for hosting multiple sites on a single server. We configured name servers, DNS, zone files and virtual host files to host multiple domains on one server. We also made sure that each domain name had an SSL certificate using Let's encrypt. We hope you enjoyed this course. If you're looking for a much more in depth course on server configuration and Web development, please be sure to check out our Web development masterclass. In the Web development masterclass, we offer a much more comprehensive guide to server configuration. Also, the course takes you from beginner to expert encoding and creating dynamic, database driven Web applications using the latest scripting languages. Thank you and we'll see you in the next course