Sharing Ilmu

Sharing for useful things

How To Configuration Apache2 (Custom html directory) ubuntu server 20.04

In preceding tutorial I have discuss about How To Install webserver (Apache,PHP) ubuntu server 20.04 and in this article I’ll discuss about how to configuration custom html directory in apache2 service.

First, Make sure you has been install the apache2 webserver. Then change directory  /etc/apache2/sites-available/ directory.

root@Taufik:~# cd /etc/apache2/sites-available/
root@Taufik:/etc/apache2/sites-available#

 

Copy default configuration file to new configuration file.

root@Taufik:/etc/apache2/sites-available# cp 000-default.conf website.conf

 

Edit the website.conf

root@Taufik:/etc/apache2/sites-available# nano website.conf

Change the DocumentRoot path.

<VirtualHost *:80>
              # The ServerName directive sets the request scheme, hostname and port that
              # the server uses to identify itself. This is used when creating
              # redirection URLs. In the context of virtual hosts, the ServerName
              # specifies what hostname must appear in the request's Host: header to
              # match this virtual host. For the default virtual host (this file) this
              # value is not decisive as it is used as a last resort host regardless.
              # However, you must set it for any further virtual host explicitly.
              # ServerName www.example.com

                 ServerAdmin webmaster@localhost
                 DocumentRoot /var/www/html/website

            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn

              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>


Enable website.conf and disable 000-default.conf files :

root@Taufik:/etc/apache2/sites-available# a2ensite website.conf
root@Taufik:/etc/apache2/sites-available# a2dissite 000-default.conf

 

Restart apache2 service :

root@Taufik:/etc/apache2/sites-available# systemctl restart apache2

 

Create new directory  named as website in /var/www/html.

root@Taufik:~# mkdir /var/www/html/website

 

Create new file index.html in website directory

root@Taufik:~# nano /var/www/html/website/index.html

 

Fill in some text in index.html file.

Test on your browser :

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>