PART 1 (WEB SERVER): HOST WEBSITE ON UBUNTU 18.*

Learning different means and HOW-TO to host websites and all about domains...
User avatar
xpl0it
Admin
Admin
Posts: 116
Joined: Mon May 08, 2017 1:36 am
Location: 127.0.0.1
x 31
x 8
Contact:

PART 1 (WEB SERVER): HOST WEBSITE ON UBUNTU 18.*

#1

Unread post by xpl0it » Mon Oct 08, 2018 2:03 am

This tutorial assumes that you have already installed Ubuntu Server 18.* in your hosting machine. That's possible only when you've purchased VPS plans, whereby you'll be provided with a full clean host machine, thereafter you'll install an OS of your choice then begin building your server, eventually hosting your website(s) and make them publicly accessible all-over the world.
Hosting a website starts with installing a web server, an application on your Ubuntu Linux that delivers content through the Internet. This part will help you get started with Apache, the world's most popular web server. Okay, Let's start !
apache-http-server-800x445.jpg
Apache web server
apache-http-server-800x445.jpg (32.52 KiB) Viewed 606 times
It's simple in Ubuntu 18.* , instead of installing each component separately, use Tasksel to install a LAMP stack (which stands for Linux, Apache, MySQL, PHP) on your Linux Host. If Tasksel completes, skip the installation steps in each section below and continue on the steps to configure each part of the stack:

Code: Select all

$ sudo tasksel install lamp-server
Install Apache

Check for and install all system updates, and install Apache on your Linux Host:

Code: Select all

$ sudo apt update && sudo apt upgrade
$ sudo apt install apache2
Your Linux Host will download, install, and start the Apache web server.

Optimize Apache for a Linux Host 2GB RAM

Installing is very easy, but if you leave it running with the default settings, your server could run out of memory. That's why it's very vital to optimize Apache before you start hosting a website on your Linux Host.

These guidelines are designed to optimize Apache for a Linux Host with 2GB RAM, but you can use this info for any size Linux Host.There values are based on the amount of resource memory available, so if you have a Linux Host 4GB, multiply all of the values by 2 and use those numbers following your settings.
  1. Make a copy of Apache’s configuration file. You can restore the duplicate (apache2.backup.conf) if anything happens to the configuration file:

    Code: Select all

    $ sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.backup.conf
  2. Open Apache’s configuration file for editing:

    Code: Select all

    $ sudo nano /etc/apache2/apache2.conf
    This will open the file in nano, but you may use whatever text editor you are comfortable with.
  3. Add this section to the end of the file [/etc/apache2/apache2.conf]

    Code: Select all

    KeepAlive Off
    
       ...
    
       <IfModule mpm_prefork_module>
           StartServers 4
           MinSpareServers 20
           MaxSpareServers 40
           MaxClients 200
           MaxRequestsPerChild 4500
       </IfModule>
  4. Save the changes to Apache’s configuration file. If you are using nano, do this by pressing CTRL+X and then Y. Press ENTER to confirm. (If you are using Nano editor)
  5. Restart Apache to include the new settings:

    Code: Select all

    $ sudo systemctl restart apache2
You’ve successfully optimized Apache for your Linux Host, increasing performance and implementing measures to prevent excessive resource consumption. You’re almost ready to host websites with Apache.

Configure Name-based Virtual Hosts

Now that Apache is optimized for performance, it’s time to starting hosting one or more websites in your Linux Host. There are several possible methods of doing this. In this section, you’ll use name-based virtual hosts to host websites in your home directory.
  1. Disable the default Apache virtual host:

    Code: Select all

    $ sudo a2dissite *default
  2. Navigate to your /var/www/html directory:

    Code: Select all

    $ cd /var/www/html
  3. Create a folder to hold your website and its files, logs, and backups, replacing example.com with your domain name:

    Code: Select all

    $ sudo mkdir -p /var/www/html/example.com/{public_html,log,backups}
  4. Create the virtual host file for your website. Replace the example.com in example.com.conf with your domain name:

    Code: Select all

    $ sudo nano /etc/apache2/sites-available/example.com.conf
  5. Create a configuration for your virtual host. Copy the basic settings in the example below and paste them into the virtual host file you just created. Replace all instances of example.com with your domain name:

    Code: Select all

    # domain: example.com
    # public: /var/www/html/example.com/public_html/
    
    <VirtualHost *:80>
      # Admin email, Server Name (domain name), and any aliases
      ServerAdmin webmaster@example.com
      ServerName  example.com
      ServerAlias www.example.com
    
      # Index file and Document Root (where the public files are located)
      DirectoryIndex index.html index.php
      DocumentRoot /var/www/html/example.com/public_html
      # Log file locations
      LogLevel warn
      ErrorLog  /var/www/html/example.com/log/error.log
      CustomLog /var/www/html/example.com/log/access.log combined
    </VirtualHost>
  6. Save the changes to the virtual host configuration file by pressing CTRL+X and then pressing Y. Press ENTER to confirm. (If you are on nano editor)
  7. Enable your new website, replacing example.com with your domain name:

    Code: Select all

    $ sudo a2ensite example.com.conf
    This creates a symbolic link to your example.com.conf file in the appropriate directory for active virtual hosts.
  8. Reload to apply your new configuration:

    Code: Select all

    $ sudo systemctl reload apache2
  9. Repeat Steps 1-8 for any other websites you want to host on your Linux Host.
So, that's the end of part I of how to host a website in Ubuntu Server 18.* specifically installing a web server-which is Apache. Optimizing it and configuring some name-based virtual hosts. In the next session we shall learn how to install, secure and configure MySQL in the Apache server. If you've noticed we have already discussed about (L)inux and (A)pache of the LAMP stack. Nice achievement ;) We are remained with (M)ySQL and (P)HP to complete this short tutorial.

Until we meet in next session, Ciao! ;)
1 x

rootmzizi
Noob
Noob
Posts: 2
Joined: Thu Oct 04, 2018 7:16 pm
x 1
x 1

Re: PART 1 (WEB SERVER): HOST WEBSITE ON UBUNTU 18.*

#2

Unread post by rootmzizi » Mon Oct 08, 2018 11:49 am

Tisha mzee baba!!!
1 x

User avatar
xpl0it
Admin
Admin
Posts: 116
Joined: Mon May 08, 2017 1:36 am
Location: 127.0.0.1
x 31
x 8
Contact:

Re: PART 1 (WEB SERVER): HOST WEBSITE ON UBUNTU 18.*

#3

Unread post by xpl0it » Mon Oct 08, 2018 12:01 pm

Aah? Sanaa mzee baba... tunapeana masomo tuu :)
0 x

User avatar
diko
Noob
Noob
Posts: 3
Joined: Thu Nov 15, 2018 10:00 am
x 2

Re: PART 1 (WEB SERVER): HOST WEBSITE ON UBUNTU 18.*

#4

Unread post by diko » Thu Nov 15, 2018 10:19 am

Good tutor, Ni computer yenye specs gani naweza kuwa nayo ili kufanya kuwa server yangu?
1 x

User avatar
xpl0it
Admin
Admin
Posts: 116
Joined: Mon May 08, 2017 1:36 am
Location: 127.0.0.1
x 31
x 8
Contact:

Re: PART 1 (WEB SERVER): HOST WEBSITE ON UBUNTU 18.*

#5

Unread post by xpl0it » Fri Nov 16, 2018 5:59 pm

Anhaa inategemea na uzito wa website unayotaka kuihost, ila kawaida angalau iwe:

Processor: Intel core i*
RAM: >=2GB
HDD: >=500GB (Kwaajili ya kustore mafile ya website pamoja na database kwa ujumla)

Karibu sana..
0 x

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest