Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I'm unable to create a new document in /var/www/

I followed this tutorial :- How to avoid using sudo when working in /var/www?

and did as suggested, but still I'm unable to make a new document. Any suggestions ?

share|improve this question

marked as duplicate by Radu Rădeanu, Eric Carvalho, guntbert, Raja, Seth Aug 23 '13 at 16:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 1 down vote accepted

You need root permissions to write to /var/www folder. You can create/edit files in /var/www folder with sudo.

sudo gedit /var/www/myfile.html

or

sudo touch /var/www/myfile.html  # only to create a file.

Additionally,

You can choose one of your own directory as your web folder. You can create a folder in your /home directory and change the web server's folder to it.

you can replace "/var/www" string in following files into your own directory path and then you can use new directory as your www folder.

/etc/apache2/sites-available/default
/etc/apache2/sites-available/default-ssl

After changing contents of the above files, run

sudo /etc/init.d/apache2 restart

to restart webserver. Then you will be able to use new directory as the web folder.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.