<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dominik Rusac</title>
    <description>The latest articles on DEV Community by Dominik Rusac (@drusac).</description>
    <link>https://dev.to/drusac</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F376022%2Fb772988c-4af2-45d7-8d26-b6673a8ecf19.jpg</url>
      <title>DEV Community: Dominik Rusac</title>
      <link>https://dev.to/drusac</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drusac"/>
    <language>en</language>
    <item>
      <title>Modern desk setup for developers in 2020</title>
      <dc:creator>Dominik Rusac</dc:creator>
      <pubDate>Wed, 25 Nov 2020 12:36:29 +0000</pubDate>
      <link>https://dev.to/lloyds-digital/modern-desk-setup-for-developers-in-2020-9co</link>
      <guid>https://dev.to/lloyds-digital/modern-desk-setup-for-developers-in-2020-9co</guid>
      <description>&lt;p&gt;I spent a lot of time looking at different pieces of IT equipment and how to connect them most efficiently for everyday use. Every developer prefers their own type of desk setup. Some developers find one laptop enough while others like a multi-monitor setup with laptop or desktop PC. I prefer a laptop with two extra monitors while I work in the office because I find that as my perfect desk setup.&lt;/p&gt;

&lt;p&gt;You are asking why this is my perfect setup? On two big screens, I can do the main work while I am using the 3rd screen (laptop) as an additional helping screen. I use my main screen in the middle and that’s where I write the code while my second screen on the left is showing the result of the code I wrote on my main screen. Also I use my left screen for browsing the internet and reading the documentation. &lt;/p&gt;

&lt;p&gt;The laptop is on my right and depending on what I'm doing at the moment, there is usually Slack, Insomnia or Chrome DevTools opened if I am doing some JavaScript. Sometimes I think it would be nice to have a 4th screen for browsing MySQL database in phpmyadmin but I’m fine for now. 😄&lt;/p&gt;

&lt;p&gt;What would be the best way to connect every piece of hardware to a laptop?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjxx4zedqe3hkoysugr5j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjxx4zedqe3hkoysugr5j.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Content:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Efficient connection with peripherals&lt;/li&gt;
&lt;li&gt;Today's laptops...&lt;/li&gt;
&lt;li&gt;Why Type-C?&lt;/li&gt;
&lt;li&gt;How? What are the requirements?&lt;/li&gt;
&lt;li&gt;What about the second monitor?&lt;/li&gt;
&lt;li&gt;Possible problems and solutions&lt;/li&gt;
&lt;li&gt;Which monitor and how many?&lt;/li&gt;
&lt;li&gt;Laptop specifications?&lt;/li&gt;
&lt;li&gt;Keyboard and mouse&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Efficient connection with peripherals &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For sure, there also must be a headset, separate keyboard and mouse connected to my laptop. All of that must be connected with the minimum number of cables. The desk needs to be as clean as possible with the ability to quickly connect and start working. &lt;/p&gt;

&lt;p&gt;When I need to take my laptop to a meeting, I don’t want to have to disconnect a lot of cables from my laptop, and when I get back on my desk reconnect all the cables back. That’s inefficient and annoying. I needed to come up with the perfect solution on how to connect all peripherals and two extra monitors to a laptop using as few cables as possible. &lt;/p&gt;

&lt;p&gt;A lot of questions came up, but the final, perfect solution was found. Connect everything together using a single Thunderbolt 3 / Type-C cable. Type-C is the perfect solution for my problem and probably for yours too. When I get back to my desk after the meeting, plugging in one cable instantly connects the headset, keyboard, mouse, two monitors and power to my laptop and my desk is usable in a second! Isn’t that nice? I love it. To achieve that level of connectivity, your equipment must support it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Today's laptops... &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Many modern laptops have fewer connectivity options than older laptops. Few years ago, laptops had VGA, HDMI and Display port built-in, so you could easily connect multiple monitors using a few cables. Today that's not the case. For example, the new Apple Macbook has only 4 ports and they are all the same - Type-C/Thunderbolt which means no VGA, HDMI or Display port connectivity.&lt;/p&gt;

&lt;p&gt;I found out that's also the case with other brands, the more expensive the laptop is the fewer ports it has. That’s a little bit odd, don’t you think? It is, but the premium laptop has premium connectivity ports, and the premium connectivity port today is Type-C / Thunderbolt port.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Type-C? &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;On cheap laptops, you’ll hardly find a Type-C/Thunderbolt port. Cheaper non-premium laptops still have some ports for connecting to external displays, most common today are HDMI and DisplayPort. Connecting through these you can get video and audio to your monitor, but you still need to connect the keyboard and mouse to your laptop via USB. And also you need your laptop charger plugged in. That’s like 4 cables already connected to a laptop which is really messy. So how can we fix that? Type-C to the rescue! &lt;/p&gt;

&lt;p&gt;Type-C can do all that through one cable. Yes, you read that correctly. To achieve that, it is required to have a Type-C supported monitor. Once your laptop is connected to your monitor via Type-C cable, you can connect all of your peripherals to that monitor. Through the monitor everything is connected to a laptop via single Type-C cable. Boy, that’s clean!&lt;/p&gt;

&lt;h3&gt;
  
  
  How? What are the requirements? &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;To be able to connect your setup this way, your hardware must support it. For sure, you must have Type-C/Thunderbolt port on your laptop and at least one Type-C external monitor. &lt;/p&gt;

&lt;p&gt;When you buy a Type-C monitor you should also get a Type-C cable in the box, at least that’s the case with Dell’s monitors. You should use that cable to connect your laptop to the monitor. Once connected, since the monitor has a 3.5 audio jack and multiple USB ports, you can easily connect your headset, mouse, keyboard, smartphone and all other devices you use to your monitor. All of that is instantly connected to your laptop through the single Type-C cable.&lt;/p&gt;

&lt;p&gt;Another great thing about Type-C is that you don’t need to use your laptop charger because the monitor provides power to your laptop through the same Type-C cable. Single Type-C cable carries power, data, display and audio all at once. How awesome is that?&lt;/p&gt;

&lt;h3&gt;
  
  
  What about the second monitor? &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Now we have connected one monitor, keyboard, mouse and headset to our laptop using only one cable. How to connect the second monitor to our setup? It’s pretty simple as long as your monitor supports MST (Multi-Stream Transport), also known as Daisy Chaining. If your monitor has one display port input (DP IN) and one display port output (DP OUT) that means your monitor supports MST/Daisy Chain, but to be sure take a closer look into monitor specifications.&lt;/p&gt;

&lt;p&gt;The first monitor your laptop is connected to via Type-C cable should support MST/Daisy Chain. You simply use a display port cable to connect the first monitor to your second monitor. In the first monitor (the one connected to laptop via Type-C), plug your display port cable in DP OUT and on the second monitor plug that same display port cable in DP IN port. You got two monitors connected to your laptop all together with all of your peripherals that go into your laptop through one single Type-C cable. Let me repeat, ONE cable!&lt;/p&gt;

&lt;h3&gt;
  
  
  Possible problems and solutions &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you don’t get a picture on some of your monitors, first make sure the proper input source is set up in the monitor settings. The first monitor input source must be set on “Type-C” while the second monitor input source must be set on “Display port”.&lt;/p&gt;

&lt;p&gt;Also, MST must be turned on in your first monitor settings so you are able to get a picture on the second display. If you still have problems after that make sure you are using DP v1.2 cable or newer. If you don’t get a picture even on the first monitor, try to use higher quality Type-C cable. Not every Type-C cable is gonna work, but the cable that comes in a box with a monitor should always work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which monitor and how many? &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;The number of monitors mostly depends on what you prefer and how you work. The more monitors you have, the more space you have to work on without minimizing the windows all the time. That way it’s faster and easier to work and because of that you are more efficient and you make more money! 💵&lt;/p&gt;

&lt;p&gt;While choosing the new monitor, make sure it supports MST/Daisy Chaining and Type-C connectivity. Dell has a lot of nice Type-C monitors, for example, U2419HC is the one that supports everything you need to connect to the laptop the way I described. Look for letter “C” in the model name to be sure it supports Type-C connectivity. Also make sure that monitor has sufficient USB ports on the back and audio jack for connecting headphones.&lt;/p&gt;

&lt;p&gt;I wouldn’t recommend a monitor sized under 24-inches, if possible go with a 27-inch with a 2K resolution. Full HD is fine on a 24-inch, but on a 27-inch monitor it’s not that good. IPS panel type would probably be the best, also VA is fine except for some lower viewing angles, as long as you sit in front of it, it will be fine and will probably have a better contrast.&lt;/p&gt;

&lt;h3&gt;
  
  
  Laptop specifications &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Always look for the best laptop your money can buy. Don’t buy the first laptop you see, do your research. I recommend a configuration with at least 12 GB RAM (don’t go under 8 GB) and Intel i5 CPU. A dedicated GPU is a plus but not required. SSD is a must with a capacity of 250/500 GB. Make sure it has at least one Type-C/Thunderbolt port, other ports like USB Type A and audio jack are welcome.&lt;/p&gt;

&lt;p&gt;The ideal screen size for a laptop would be 14” because it’s in the perfect middle of 13” and 15” laptop screens. I left out 17” laptops because they are too big and heavy to carry around. I wouldn’t mind a 13” laptop as long as I am using two external monitors with it. Still, 14” seems ideal with of course Full HD resolution or better.&lt;/p&gt;

&lt;p&gt;A bigger battery means longer battery life and battery life is important. Look for around 50-60 Wh battery which should get you through the day. High quality keyboard and touchpad is also a thing you should worry about - you don't want laggy touchpad or squeaky keyboard. Overall laptop build quality is better the more money you spend. Also, you will pay more for a thinner and lighter laptop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keyboard and mouse &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This mostly depends on your preferences and budget. Whether you want classic, mechanical, small size (tenkeyless) or a full size keyboard. I currently use Logitech K280 wired keyboard which is fine but... I am looking at you Logitech MX keys.&lt;/p&gt;

&lt;p&gt;I use Logitech G502 wired mouse and I find it almost perfect, it has all the extra buttons I need. There is also an even better G502 Lightspeed which is practically identical but wireless. You could pair your wireless mouse with wireless charging mousepad so you don't need to worry about the battery.&lt;/p&gt;

&lt;p&gt;Choose what suits you best and go wireless for an even cleaner desk setup!&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;A desk that makes you comfortable and suits your needs is a productive desk. Make sure you organize it the way you want as this will lead you to grow and become a better and more efficient developer!&lt;/p&gt;

&lt;p&gt;Happy coding everyone!&lt;/p&gt;




&lt;p&gt;Thank you for reading this! If you've found this interesting, consider leaving a ❤️, 🦄, and of course, share and comment your thoughts!&lt;/p&gt;

&lt;p&gt;Lloyds is available for partnerships and open for new projects. If you want to know more about us, click &lt;a href="https://lloyds-design.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, don’t forget to follow us on &lt;a href="https://www.instagram.com/lloyds.design/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://www.facebook.com/lloydsgn/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>modern</category>
      <category>desk</category>
      <category>setup</category>
      <category>developer</category>
    </item>
    <item>
      <title>How to make your web server better and more stable</title>
      <dc:creator>Dominik Rusac</dc:creator>
      <pubDate>Fri, 04 Sep 2020 14:01:38 +0000</pubDate>
      <link>https://dev.to/lloyds-digital/how-to-make-your-web-server-better-and-more-stable-4jed</link>
      <guid>https://dev.to/lloyds-digital/how-to-make-your-web-server-better-and-more-stable-4jed</guid>
      <description>&lt;p&gt;Welcome to the second part of the &lt;em&gt;"Serving website from home"&lt;/em&gt; serie. In this one we'll talk about making our web server more useful and complete. We'll talk about buying a domain name, pointing it to our server and then creating subdomains so we could host multiple websites from a single server instance. After that, to make websites more secure, we'll go through the installation of the SSL certificates. &lt;/p&gt;

&lt;p&gt;Finally, we'll set up some cron jobs to make our server more stable and I will leave you with some ideas on how to achieve 99% of your home server uptime. Stay tuned!&lt;/p&gt;




&lt;h2&gt;
  
  
  Content:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Get your domain name&lt;/li&gt;
&lt;li&gt;Point domain to your server&lt;/li&gt;
&lt;li&gt;Creating subdomains&lt;/li&gt;
&lt;li&gt;Configure Apache base domain&lt;/li&gt;
&lt;li&gt;Configure Apache subdomain&lt;/li&gt;
&lt;li&gt;Installing SSL certificates&lt;/li&gt;
&lt;li&gt;Improve server uptime using Cron jobs&lt;/li&gt;
&lt;li&gt;Improve server uptime - ideas&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Following through my &lt;a href="https://dev.to/lloyds-digital/how-you-can-host-websites-from-home-4pke"&gt;previous blog&lt;/a&gt; you should have your basic website up and running from your home. Now it's time to level up your web server. Let's start by getting your domain name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get your domain name &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;You can buy a domain name from numerous different sites. For example, some of them are &lt;a href="https://www.namecheap.com/" rel="noopener noreferrer"&gt;Namecheap&lt;/a&gt;, &lt;a href="https://www.godaddy.com/" rel="noopener noreferrer"&gt;GoDaddy&lt;/a&gt;, &lt;a href="https://aws.amazon.com/route53/" rel="noopener noreferrer"&gt;AWS Route 53&lt;/a&gt;. I personally use Namecheap and it works fine for me. I recommend using Namecheap if you still aren't registered with some other domain provider because it will be easier for you to follow along. If you use some other provider, there shouldn't be any drastic differences in steps, so you'll probably be fine.&lt;/p&gt;

&lt;p&gt;Go to the chosen provider site and search for a domain name you like. If the domain name is already taken, try to think of something similar of your liking. Once you found your domain name, add it to cart. You will probably be offered some extra stuff that goes with your domain, for example you could add an SSL certificate to your domain for extra $3 or $4 per year, but you don't need any of that, the domain name itself is enough, we will install the SSL certificate for free by using Let's Encrypt.&lt;/p&gt;

&lt;p&gt;Once you bought your chosen domain name, you should see it on the domain list in your account. There you can manage your domain names, which takes us to pointing the domain to our web server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Point a domain to your server &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Pointing the domain names to your web server is a fairly simple thing to do. I use Namecheap but any other provider should have the same settings within a different user interface. &lt;/p&gt;

&lt;p&gt;In your domain names list, click "Manage" button to access details of a certain domain name and then go to tab "Advanced DNS". There you can simply point domain or subdomain name to your network public IP address. The most simple way to find your public IP address is to visit &lt;a href="http://icanhazip.com/" rel="noopener noreferrer"&gt;icanhazip.com&lt;/a&gt; from any device connected to the same network as your web server.&lt;/p&gt;

&lt;p&gt;Now we are ready to point domain names to our network IP address. In my case, domain name that I bought is "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;". Follow the picture below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1351rp0a6wwjdbx54q0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F1351rp0a6wwjdbx54q0q.png" alt="Namecheap domain names"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First Type A record with a host value of "@" represents where to point "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" domain name. IP address value for every Type A record should be your network public IP address (address of your web server), and TTL set to automatic. &lt;/p&gt;

&lt;p&gt;Time to live (TTL) is the amount of time your old DNS record could still show up the old value after you change your DNS record. For example, if you set a TTL value to 30 minutes, that means that the DNS servers around the world could still be showing the old value from their cache for up to 30 minutes after the change. &lt;/p&gt;

&lt;p&gt;When creating a new DNS record, keep in mind that it can take a while to propagate all over the world. Usually, it takes a few minutes, you can use &lt;a href="https://www.whatsmydns.net/" rel="noopener noreferrer"&gt;whatsmydns.net&lt;/a&gt; to check your propagation status. Just enter domain name you want to check and select "A" type from dropdown menu and click search. You will get a list of countries and IP address you see should be your network public IP address.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy4ue85xd0b5xwdn3rgsb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy4ue85xd0b5xwdn3rgsb.png" alt="Whats my dns"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you get a green check that means it's propagated in that country and it points to listed IP address - the public IP address of your network/web server which means domain pointing is properly done. Good job!&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating subdomains &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Second Type A record with host value of (in my case) "photos" should also point to network public IP address. By creating Type A record with a "photos" value we actually created a subdomain "&lt;a href="https://photos.rusac.dev/" rel="noopener noreferrer"&gt;photos.rusac.dev&lt;/a&gt;" and pointed it to our server address. I also have a third Type A record with "projects" host value which means I have another subdomain "&lt;a href="https://photos.rusac.dev/" rel="noopener noreferrer"&gt;photos.rusac.dev&lt;/a&gt;" - you get the idea. &lt;/p&gt;

&lt;p&gt;This way you can create as many subdomains as you like and point them all to your web server. Once a web request comes to our web server, our Apache server will serve the appropriate website to the user. That will happen, of course, when we configure it to do so.&lt;/p&gt;

&lt;p&gt;You may have noticed, apart from three Type A records, there are also three CNAME records. First one has a host value of "www" which means we are talking about "&lt;a href="http://www.rusac.dev" rel="noopener noreferrer"&gt;www.rusac.dev&lt;/a&gt;" domain with a value of "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;". That means "&lt;a href="https://www.rusac.dev/" rel="noopener noreferrer"&gt;www.rusac.dev&lt;/a&gt;" points to "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" and "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" using Type A record points to our server IP address. This way we will get to "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" website no matter if we enter "&lt;a href="https://www.rusac.dev/" rel="noopener noreferrer"&gt;www.rusac.dev&lt;/a&gt;" or "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" in our web browser.&lt;/p&gt;

&lt;p&gt;You can check this using the &lt;a href="//whatsmydns.net"&gt;whatsmydns.net&lt;/a&gt;, enter subdomain name, select CNAME type from dropdown list and click search. You should get a similar result as shown on the picture below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm3u1yz4ewqqutf4de5jz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm3u1yz4ewqqutf4de5jz.png" alt="CNAME record check"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Second CNAME record with a host value of "&lt;a href="http://www.photos" rel="noopener noreferrer"&gt;www.photos&lt;/a&gt;" refers to "&lt;a href="https://www.photos.rusac.dev/" rel="noopener noreferrer"&gt;www.photos.rusac.dev&lt;/a&gt;" domain and points to "&lt;a href="https://photos.rusac.dev/" rel="noopener noreferrer"&gt;photos.rusac.dev&lt;/a&gt;" domain which via Type A record points to our server IP address. Same goes for the third CNAME record. Creating CNAME records is not required, but is recommended because this way subdomains will be accessible starting with a "www" subdomain/prefix.&lt;/p&gt;

&lt;p&gt;To summarize, my main domain name which I bought is "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;". Under my main domain I have three subdomains: "&lt;a href="https://www.rusac.dev/" rel="noopener noreferrer"&gt;www.rusac.dev&lt;/a&gt;", "&lt;a href="https://photos.rusac.dev/" rel="noopener noreferrer"&gt;photos.rusac.dev&lt;/a&gt;" and "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;". We can observe "www" subdomain the same way as "photos" or "projects" subdomains. It's as simple as that. Now that we have our subdomain DNS records created, it's time to configure our Apache server to serve requested website to the user.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure Apache base domain &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I'll explain how I set up "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" domain and "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" subdomain names. This way it will be easy for you to follow up using your preferred domain names.&lt;/p&gt;

&lt;p&gt;First of all, create your website folder. You can name it however you want but good practice would be naming it the same way your domain name is except for using hyphen instead of a period, because it's cleaner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir /var/www/rusac-dev       // Create website folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After creating website folder you can &lt;em&gt;git clone&lt;/em&gt; your website inside or you can simply create basic "index.html" file with some example HTML markup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /var/www/rusac-dev/index.html    // Create index.html file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example HTML markup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Hello World!&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Welcome to my personal website!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our website is ready and the next thing to do is to create Apache configuration file. Use the following command to create .conf file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/apache2/sites-available/rusac.dev.conf 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside "your.domain.name.conf" file paste the following configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;VirtualHost *:80&amp;gt;
    ServerAdmin dominik@lloyds.design
    ServerName rusac.dev
    ServerAlias www.rusac.dev
    DocumentRoot /var/www/rusac-dev

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure you replace ServerAdmin, ServerName, ServerAlias and DocumentRoot with your corresponding values. ServerAdmin value should be your email address, ServerName should be your domain name (Type A record) while ServerAlias should be your subdomain (CNAME record) which points to Type A record of the domain. Finally, DocumentRoot is a path to the website which you want to serve on the specified domains.&lt;/p&gt;

&lt;p&gt;Now we have our website and configuration ready, awesome! We are almost there. All there is to do now is to test configuration, enable our website and restart Apache server. Use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apache2ctl configtest    // Should return Syntax OK message
sudo a2ensite rusac.dev.conf    // Enable website
sudo systemctl restart apache2    // Restart Apache server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your Apache server should now serve your website globally! If you were following my setup, you can access it with or without "www" subdomain/prefix. So in my case, Apache serves the same website to both "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" and "&lt;a href="https://www.rusac.dev/" rel="noopener noreferrer"&gt;www.rusac.dev&lt;/a&gt;" domains.&lt;/p&gt;

&lt;p&gt;NOTE: If you bought .dev domain like me, your website will not work until you install an SSL certificate because .dev domains require SSL certificate by default. You will get "Your connection is not private" message. So our next step is obtaining a free SSL certificate using Let's Encrypt.&lt;/p&gt;

&lt;p&gt;Before installing an SSL certificate, let's quickly set up  a website for "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" subdomain. Process is almost the same as for the base "&lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt;" domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure Apache subdomain &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Create website folder and "index.html" file inside with example HTML markup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir /var/www/projects-rusac-dev       // Create website folder
sudo nano /var/www/projects-rusac-dev/index.html    // Create index.html file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example HTML markup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Hello World!&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Welcome to my projects website!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/apache2/sites-available/projects.rusac.dev.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fill it with your subdomain values and DocumentRoot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;VirtualHost *:80&amp;gt;
    ServerAdmin dominik@lloyds.design
    ServerName projects.rusac.dev
    ServerAlias www.projects.rusac.dev
    DocumentRoot /var/www/projects-rusac-dev

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check for errors, enable site and finally restart Apache server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apache2ctl configtest    // Should return Syntax OK message
sudo a2ensite projects.rusac.dev.conf    // Enable website
sudo systemctl restart apache2    // Restart Apache server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our website on "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" subdomain is now online and accessible with or without "www" subdomain/prefix. Let's proceed to installing SSL certificates on our domains.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing SSL certificates &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I will install SSL certificates for "&lt;a href="https://www.projects.rusac.dev/" rel="noopener noreferrer"&gt;www.projects.rusac.dev&lt;/a&gt;" and "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" domain names. Process is the same for any other domain. Before continuing, make sure your "Apache Full" firewall profile is active and allows traffic through port 80 and 443 (SSL). Check that using the following command and allow "Apache Full" if needed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw status    // Check firewall status
sudo ufw allow 'Apache Full'    // Run if profile is not active
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Find and follow &lt;a href="https://certbot.eff.org/instructions" rel="noopener noreferrer"&gt;certbot instructions&lt;/a&gt; to install certbot on your server. Certbot will help you to easily install SSL certificates on your websites. Once installed, run it using this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --apache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get a numbered list of your Apache enabled sites. Choose sites for which you want to obtain SSL certificate by entering numbers separated by commas or spaces, then press enter. I entered numbers of "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" and "&lt;a href="http://www.projects.rusac.dev" rel="noopener noreferrer"&gt;www.projects.rusac.dev&lt;/a&gt;" domain names.&lt;/p&gt;

&lt;p&gt;Certificates will start obtaining and you will be asked whether or not to redirect HTTP traffic to HTTPS. Enter number 2 because we want all traffic going through secure HTTPS with removing non-secure HTTP access. See the picture below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcfcka3bgos72iflvfsyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcfcka3bgos72iflvfsyh.png" alt="ssl certificate install"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If everything goes well, you'll get congratulations message and SSL certificates installed. That's it! Also you'll get links where you can go to test your SSL configuration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Improve server uptime using Cron jobs&lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you happen to have a dynamic IP address like I do then you have a problem. Every time your IP address changes, your websites will be down because your domains will point to your old IP address. To fix this, you would need to update your DNS records at least once a day, which is really frustrating and we wanna automate that. Fortunately, Namecheap offers a solution. &lt;/p&gt;

&lt;p&gt;You can set up a cron job on your server which sends out request to Namecheap every X minutes and update your DNS records with your current server public IP address. For example, if you send out a request from  your server every 15 minutes that means your maximum server downtime per IP change would be less than 15 minutes. If you send out a request every minute, then you'll get much better server uptime. I chose to send request every 15 minutes which works fine for me.&lt;/p&gt;

&lt;p&gt;Check Namecheap &lt;a href="https://www.namecheap.com/support/knowledgebase/article.aspx/29/11/how-do-i-use-a-browser-to-dynamically-update-the-hosts-ip" rel="noopener noreferrer"&gt;instructions&lt;/a&gt; on how to build URL for updating your domain DNS records. You will need your Dynamic DNS password which could be found in advanced DNS settings of your domain.&lt;/p&gt;

&lt;p&gt;If you are not using Namecheap, check if your domain provider offers this or similar possibility. I will explain my cron job example for updating DNS records of "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" domain.&lt;/p&gt;

&lt;p&gt;Open cron tasks using command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the bottom of the file add the following line, then save and exit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*/15 * * * * curl "https://dynamicdns.park-your-domain.com/update?host=projects&amp;amp;domain=rusac.dev&amp;amp;password=your_namecheap_dyndns_password" &amp;gt; /home/dominik/projects.rusac.dev.log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "curl" command will run every 15 minutes and will make a request to the specified URL. In this case, sending a request will update the DNS records for "&lt;a href="https://projects.rusac.dev/" rel="noopener noreferrer"&gt;projects.rusac.dev&lt;/a&gt;" domain and will save the result to "projects.rusac.dev.log" file. You can create as many cron jobs as you need. Create a cron job for each domain/subdomain whose DNS records must be updated regularly.&lt;/p&gt;

&lt;p&gt;Created cron job will be updating our DNS records every 15 minutes, so if your website is down, wait for up to 15 minutes and your website will be back online, of course that is if everything else is set up properly.&lt;/p&gt;

&lt;p&gt;There are a lot of crontab generators online which can help you create your cron job the way you want it. For example check out &lt;a href="https://crontab-generator.org/" rel="noopener noreferrer"&gt;Crontab Generator&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Improve server uptime - ideas &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;No matter how good your server configuration setup is, your server uptime will mostly be defined by your internet connection. Since quality of your internet connection isn't up to you, there is not much you can do about it. You can look up the offers from different internet providers in your area and maybe even consider switching to 4G internet. I recently switched to 4G internet and got 3x faster download speed and 10x faster upload speed which came very nice since I'm hosting websites from home.&lt;/p&gt;

&lt;p&gt;Besides bad internet connection, other thing that can affect your server uptime is the bad weather. What if the power goes out due to thunderstorm? No power means our server is down! What can we do about it? &lt;/p&gt;

&lt;p&gt;Well we could invest in uninterruptible power supply (&lt;a href="https://en.wikipedia.org/wiki/Uninterruptible_power_supply" rel="noopener noreferrer"&gt;UPS&lt;/a&gt;) unit which will keep our server and 4G router running for some time when the main power goes out. You can think of it as a powerbank for a server. This way bad weather will be having a hard time bringing our server down. 💪&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Having a server configured as described in the blog with UPS connected, stable internet connection and cron jobs set up to update DNS records every minute or two, we could achieve 99% of our server uptime in theory. 🎉&lt;/p&gt;

&lt;p&gt;This is more than good enough for serving a personal website like &lt;a href="https://rusac.dev/" rel="noopener noreferrer"&gt;rusac.dev&lt;/a&gt; which can afford some downtime without consequences. Of course, you could also deploy a production website or application but I wouldn't recommend doing so because the downtime in production environment is not acceptable.&lt;/p&gt;

&lt;p&gt;Setting up your own server comes in handy for testing websites if you are into web development and also it's very educational.&lt;/p&gt;




&lt;p&gt;Thank you for reading this! If you've found this interesting, consider leaving a ❤️ or 🦄, and of course, share and comment your thoughts!&lt;/p&gt;

&lt;p&gt;Lloyds is available for partnership and open for new projects. If you want to know more about us, click &lt;a href="https://lloyds-design.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;Also, don’t forget to follow us on &lt;a href="https://www.instagram.com/lloyds.design/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://www.facebook.com/lloydsgn/" rel="noopener noreferrer"&gt;Facebook&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>domain</category>
      <category>ssl</category>
      <category>cron</category>
      <category>apache</category>
    </item>
    <item>
      <title>How you can host websites from home</title>
      <dc:creator>Dominik Rusac</dc:creator>
      <pubDate>Tue, 09 Jun 2020 07:06:05 +0000</pubDate>
      <link>https://dev.to/lloyds-digital/how-you-can-host-websites-from-home-4pke</link>
      <guid>https://dev.to/lloyds-digital/how-you-can-host-websites-from-home-4pke</guid>
      <description>&lt;p&gt;Have an old PC or laptop that you are not using anymore? Well, guess what? You can turn it into a web server and host your website from your home network to the whole world! If you happen to have a Raspberry Pi, that’s even better because Pi is silent and very low on power consumption. &lt;br&gt;
However, any computer that can run Ubuntu or similar OS will do just fine! &lt;/p&gt;

&lt;p&gt;We will talk about network setup, firewall, Apache, virtual hosts, dynamic IP problem and more. Go make yourself a cup of coffee and dive into building your own web server at home!&lt;/p&gt;



&lt;p&gt;Requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PC/Laptop/Raspberry Pi with &lt;a href="https://ubuntu.com/download"&gt;Ubuntu&lt;/a&gt;/&lt;a href="https://ubuntu.com/download/server"&gt;Ubuntu Server&lt;/a&gt; OS installed&lt;/li&gt;
&lt;li&gt;Username and password for accessing router settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’ll talk about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Port forwarding&lt;/li&gt;
&lt;li&gt;Initial server and firewall configuration&lt;/li&gt;
&lt;li&gt;Installing Apache web server on Ubuntu&lt;/li&gt;
&lt;li&gt;Setting up Apache virtual hosts&lt;/li&gt;
&lt;li&gt;Useful commands&lt;/li&gt;
&lt;li&gt;Dynamic IP problem&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For setting up web server I will use Raspberry Pi 3 with Ubuntu 18.04 LTS installed. Always look for LTS (Long Term Support) version of Ubuntu when downloading it from the official website. If you are confident with terminal, you can also use &lt;a href="https://ubuntu.com/download/server"&gt;Ubuntu Server&lt;/a&gt;. At the time of writing this blog, the latest Ubuntu LTS version is 20.04 and is supported until April 2025.&lt;/p&gt;
&lt;h3&gt;
  
  
  Port forwarding &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Once you have your Ubuntu up and running, the first thing I recommend doing is to configure port forwarding on your home network. We are doing this to enable access to our web server over the internet. You can do this using any computer that is connected to your home network. &lt;/p&gt;

&lt;p&gt;To access your router settings, you need default gateway IP address. To get it use Command Prompt/Terminal and enter one of three commands, depending on which OS you are currently using. Default gateway IP address is usually 192.168.1.1 or similar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ipconfig | findstr /i "Gateway"       // Windows - Command Prompt
    ip r | grep default                   // Ubuntu - Terminal
    route get default | grep gateway      // Mac OS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you find your default gateway IP address, enter it in your web browser. You will need to enter the username and password to log in and get access to router settings. Those credentials could often be found at the bottom of a router, usually on a small sticker. If not, you can look online to find out the default credentials for your router model. &lt;/p&gt;

&lt;p&gt;When you successfully log in, look for “Port forwarding” or “Virtual Servers Setup”. Different routers can name the same settings differently. You need to add two new entries to allow traffic through ports 22 for SSH and 80 for web server. &lt;/p&gt;

&lt;p&gt;To do that correctly, you need the local IP address of the computer which will be used as a web server. In my case it’s Raspberry Pi which is on Ubuntu so to get Raspberry Pi local IP address all I have to do is open Terminal and enter this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    hostname -I
    // 192.168.1.22
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Raspberry Pi local IP address is similar but for sure different from default gateway IP address. We need to point incoming requests to our local server address and we’ll do that through ports 22 and 80, that’s why we need our local server IP address. &lt;/p&gt;

&lt;p&gt;So, in your router settings, you need to add those two ports to allow traffic through them to your local server IP address. When adding port 22 you can name it “SSH”, under “Server IP Address” enter your local server IP (in my case it’s 192.168.1.22) and under “External/Internal Port Start/End” enter “22”. Use TCP protocol. Do the same for port 80 and name it “Apache”. &lt;/p&gt;

&lt;p&gt;Ok, now you have these ports configured on the router side. Go to &lt;a href="https://canyouseeme.org/"&gt;canyouseeme.org&lt;/a&gt; and check if ports 22 and 80 are opened. There are two fields, “Your IP” which shows you your public IP address and “Port to check”. Simply enter port number 22 or 80 and click “Check Port”. &lt;/p&gt;

&lt;p&gt;Don’t worry if you get an “Error: I could not see your service on your_ip on your_port”, that’s perfectly fine. That’s because the firewall on your server is doing a good job blocking all disallowed connections. We will get to that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Initial server and firewall configuration &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;On a freshly installed Ubuntu, it’s a good idea to do some basic server configuration so the server is ready for future use. To start configuring, open Terminal on your server (in my case Raspberry Pi) and follow along. &lt;/p&gt;

&lt;p&gt;First of all, we'll create a new user which we’ll use to log in into the server over SSH, both inside and outside of our home network (local and external). Also, we will set a new user as “superuser” which means it will have root privileges. &lt;/p&gt;

&lt;p&gt;This allows our new user to run commands with administrative privileges by putting the word “sudo” before each command. When creating a new user you will have to enter a password and some basic user info.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo adduser john                  // create new user john
    sudo usermod -aG sudo john         // add user john to sudo group
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our new Ubuntu user should now be ready, but before we can log in over SSH, we need to configure a firewall. We need to allow port 22 through the firewall so we can log in with our new user over SSH, both locally and externally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo ufw status numbered          // check current firewall status
    sudo ufw allow OpenSSH            // allow port 22 through firewall
    sudo ufw enable                   // enable firewall
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By enabling firewall and allowing port 22 through, now it’s possible to connect to our server using SSH. You should be able to connect to the server from any computer connected to your local network, and also if you have done port forwarding right you should be able to connect from anywhere in the world. &lt;/p&gt;

&lt;p&gt;To connect to your server simply use Command Prompt or Terminal and enter the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ssh john@192.168.1.22             // local connection - use your local server IP
    ssh john@xxx.xxx.xxx.xxx          // external connection - use your public IP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to connect externally, outside your local network, you can find your public IP at &lt;a href="https://canyouseeme.org/"&gt;canyouseeme.org&lt;/a&gt; and also if you now check if port 22 is opened, you should get “Success: I can see your service on your_ip on port 22”. That means port forwarding and initial server setup are properly done. Good job!&lt;/p&gt;

&lt;h3&gt;
  
  
  Install Apache web server on Ubuntu &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Apache web server is one of the most popular web servers and it’s fairly simple to install.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo apt-get update               // update available software list
    sudo apt install apache2          // install apache2 package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apache is now installed and to make it work it’s necessary to modify firewall settings to allow external access to Apache web server. &lt;/p&gt;

&lt;p&gt;Earlier we opened port 22 for connecting over SSH, now we need to open port 80 for Apache. If you are planning to install an SSL certificate on your website I recommend using the “Apache Full” profile which opens both 80 and 443. For non-SSL website “Apache” profile which opens only port 80 will do just fine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo ufw app list                 // list ufw application profiles
    // Available applications:
    //   Apache
    //   Apache Full
    //   Apache Secure
    //   OpenSSH

    sudo ufw allow 'Apache'           // opens port 80
    sudo ufw allow 'Apache Full'      // opens port 80 and 443
    sudo ufw allow 'Apache Secure'    // opens port 443 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you check your current firewall status, you should get a similar output. A firewall is now allowing traffic through port 80 if you used the “Apache" profile, and also through port 443 if you used the “Apache Full” profile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo ufw status                   // current firewall status
    // Status: active

    // To                         Action      From
    // --                         ------      ----
    // Apache Full                ALLOW       Anywhere
    // OpenSSH                    ALLOW       Anywhere
    // Apache Full (v6)           ALLOW       Anywhere (v6)
    // OpenSSH (v6)               ALLOW       Anywhere (v6)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go on &lt;a href="https://canyouseeme.org/"&gt;canyouseeme.org&lt;/a&gt; and check if port 80 is opened. If you get “Success: I can see your service on your_ip on port 80” that means your server is accessible from the internet. Awesome!&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up Apache virtual hosts &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Before configuring Apache to serve your own website, if you check Apache status you should get “active (running)”. To check if your website works locally enter local IP server address in your internet browser (in my case that’s 192.168.1.22).&lt;/p&gt;

&lt;p&gt;For checking if your website is available on the internet I suggest using your smartphone. Turn off your Wi-Fi and use the mobile internet (3G/4G). Open your internet browser and enter the public IP address of your home network. If you get to default Apache landing page you can be sure your server is up and running!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo systemctl status apache2   // check apache status
    hostname -I                  // get local server IP address like 192.168.1.22
    curl -4 icanhazip.com        // get public IP address of your home network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apache by default serves documents from the &lt;em&gt;/var/www/html&lt;/em&gt; directory. We’ll leave this directory as is and create our new directory which we’ll use to serve our website from.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo mkdir /var/www/mywebsite
    sudo nano /var/www/mywebsite/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside “mywebsite” directory, we’ll create an “index.html” file and paste some basic HTML markup, save and close the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Hello World!&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;My website is live!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order for Apache to serve this website, it’s necessary to create a new virtual host (&lt;em&gt;.conf&lt;/em&gt;) file. The default configuration file is located at &lt;em&gt;/etc/apache2/sites-available/000-default.conf&lt;/em&gt; and we’ll also leave this file as is and create our new &lt;em&gt;mywebsite.conf&lt;/em&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo nano /etc/apache2/sites-available/mywebsite.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside &lt;em&gt;mywebsite.conf&lt;/em&gt; file paste following configuration which is similar to the default one, but updated with your ServerAdmin, ServerName and DocumentRoot.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;VirtualHost *:80&amp;gt;
        ServerAdmin your@email.com             // your email
        ServerName xxx.xxx.xxx.xxx             // your public IP address
        DocumentRoot /var/www/mywebsite        // document root of your website
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    &amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, we need to enable created website using &lt;em&gt;a2ensite&lt;/em&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo a2ensite mywebsite.conf         // enable mywebsite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don’t forget to disable Apache default website using &lt;em&gt;a2dissite&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo a2dissite 000-default.conf      // disable default Apache website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run test for configuration errors. You should get a “Syntax OK” message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo apache2ctl configtest
    // Syntax OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, restart the Apache server for the changes to take effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    sudo systemctl restart apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On your smartphone, open your web browser and type in your public IP address and hit enter. If you see “My website is live!” text, you have successfully configured your Apache web server, congratulations!&lt;/p&gt;

&lt;h3&gt;
  
  
  Useful commands &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Here are some commands that you might find useful while configuring your server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    // UFW Firewall commands
    sudo ufw allow OpenSSH
    sudo ufw allow Apache
    sudo ufw status numbered
    sudo ufw delete X

    // SSH server commands
    sudo systemctl status ssh
    sudo systemctl stop ssh
    sudo systemctl start ssh
    sudo systemctl disable ssh
    sudo systemctl enable ssh

    // Apache server commands
    sudo systemctl start apache2
    sudo systemctl stop apache2
    sudo systemctl restart apache2
    sudo systemctl reload apache2
    sudo systemctl disable apache2
    sudo systemctl enable apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dynamic IP problem &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In most cases for home networks, the public IP address changes every 24 hours. Also if your router gets disconnected from the internet you will automatically get a new IP address when reconnected.&lt;/p&gt;

&lt;p&gt;That’s a problem because every time your IP changes, to access your website you need to use the current public IP address of your network and also you need to update Apache config file. If you have a static public IP address then you are fine. Usually, ISP charges extra for static IPs. &lt;/p&gt;

&lt;p&gt;There is a solution for this without having to pay for static IP. You can use free dynamic DNS service like &lt;a href="http://no-ip.com/"&gt;no-ip.com&lt;/a&gt; where you can choose a free domain name and point it to your public IP address. You also need to add that domain name and your no-ip.com account credentials in your dynamic DNS router settings.&lt;/p&gt;

&lt;p&gt;After you do that, your router and dynamic DNS service will work together and update your public IP address as it changes. This way, to access your website, you can always use the same domain name chosen on your dynamic DNS service as it always points to your current, up to date public IP address.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;You should now have a basic understanding of how the web server works. Setting up your own web server at home is a good way to train your server administration skills. Having knowledge of setting up a server at home, you shouldn’t have problems administrating one on AWS, DigitalOcean or similar services. &lt;/p&gt;

&lt;p&gt;Where to go from here? Well, you could buy your own domain name like &lt;em&gt;mydomain.com&lt;/em&gt; and point it to your server IP address. After that, you can create any number of subdomains like &lt;em&gt;subdomain.mydomain.com&lt;/em&gt; and host multiple different sites, all from one Apache instance. Also, it’s a good idea to install an SSL certificate on your website. But more on that later, I need to leave some content for my next blog. 😉&lt;/p&gt;

</description>
      <category>apache</category>
      <category>server</category>
      <category>ubuntu</category>
      <category>website</category>
    </item>
  </channel>
</rss>
