I've installed apache2 on ubuntu and I want to add an html page on it's root to see if it works. How can I do it?
Ubuntu – How to add an html page in the apache2 root
Apache2html
Apache2html
I've installed apache2 on ubuntu and I want to add an html page on it's root to see if it works. How can I do it?
Best Answer
The default Apache2 Document Root directory on Ubuntu is:
/var/www/html
.It is defined in the configuration file
/etc/apache2/sites-available/000-default.conf
. You can enable and disable this default virtual host via these commands:You can create other virtual hosts, that points to other directories. After each of these steps or after some edits in the configuration files you must reload (or restart) Apache2:
By default, the directory
/var/www/html
is owned by root. This means when you want to edit a file in this directory you have to usesudo
command.For example. There is a file that contains the default welcome page. This file is called
/var/www/html/index.php
. To edit it, open a terminal window (ctrl+alt+T) and use this command:It is not good practice, but for testing purposes (while using the web server only locally) you can change the owner of this directory and files in it. Use this command:
After that you will be able to edit and create files there, with your current user (try the command
echo $USER
).About the permissions of this folder, please read this topic: How to avoid using sudo when working in /var/www?