Translations:Creating a web server on a cloud/6/en
Jump to navigation
Jump to search
Change the web server's root directory
It is often much easier to manage a website if the files are owned by the user who is connecting to the VM. In the case of the Ubuntu image we're using in this example, this is user ubuntu
. Follow these steps to direct Apache to serve files from /home/ubuntu/public_html
, for example, instead of from /var/www/html
.
- Use the command (or some other editor) to change the line
[name@server ~]$ sudo vim /etc/apache2/apache2.conf
<Directory /var/www/>
to<Directory /home/ubuntu/public_html>
- Use the command to edit the line
[name@server ~]$ sudo vim /etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/html
to becomeDocumentRoot /home/ubuntu/public_html
- Create the directory in the Ubuntu user's home directory with
[name@server ~]$ mkdir public_html
- Copy the default page into the directory with
[name@server ~]$ cp /var/www/html/index.html /home/ubuntu/public_html
- Then restart the Apache server for these changes to take effect with
[name@server ~]$ sudo service apache2 restart
You should now be able to edit the file /home/ubuntu/public_html/index.html
without using sudo
. Any changes you make should be visible if you refresh the page you loaded into your browser in the previous section.