Access denied creating Apache website in /var/www
I have Ubuntu 20.04.3 in a portable drive. I installed Apache using Install and Configure Apache | Ubuntu. I was able to rename the index.html in /var/www/html and create my own index.html and it is rendered when I browse to localhost.
Then on page three it explains how to create a separate website. The instructions use gci as in /var/www/gci/ but it says we can use any name so I am using whatever. When I try to save an index.html into /var/www/whatever/ I get access denied, I am not the owner (I forget the actual words). The permissions for /var/www/whatever/ appear to me to be the same as for /var/www/html/ but I probably do not know where to look. The critical commands that the instructions say to use are: sudo mkdir /var/www/whatever/ cd /var/www/whatever/ nano index.html Is that enough information for you to suggest something to diagnose the problem? |
Yes, step four goes into making a vhost. The instructions are very sparse there, but they cover the gist which is that you copy /etc/apache2/sites-available/000-default.conf to a new file and edit the new file to set permissions for the other directory. Also, you can chown the document root directory if you are the only one using it. If you have several people editing that directory then a little more complicated solution is needed.
As for the vhost configuration, the full reference manual for Apache2 is online: http://httpd.apache.org/docs/2.4/ That is a reference manual, not a tutorial so you'll have to train up to fully benefit from it, but it is well worth doing so. There you will also find a brief tutorial about Name- and IP-based Virtual Hosts (vhosts) and their configuration. There is also a lookup list for Run-time Configuration Directives. In the list, you can look up Directory, Options, and DocumentRoot to begin with. |
Quote:
Quote:
I am switching between Windows and Ubuntu and I must remember to carry my password for this site over to Ubuntu so I can update this thread from Ubuntu. |
Ah. The filesystem permissions need to be tuned to your use case. The Apache2 vhost configuration files only determine where the web server looks for files. But in order to be able read, write, and edit the files, your account has to have permission. If you are the only person using that server, then just change ownership for the directory in question:
Code:
sudo chown -R samhobbs:samhobbs /var/www/whatever/ PS. Can I suggest a static site generator like Hugo or one of the others instead of WordPress? |
Quote:
Set the docroot directory to be 764 (chmod -R 764 /var/www/whatever), and you should be good. Permissions can be set very granular, and this lets you read/write to the directories/files in question, but need explicit root permissions to do something more serious. There are MANY guies on setting up Apache on Ubuntu...you seem to have followed the most basic, without looking any further. https://www.tecmint.com/install-apac...-ubuntu-20-04/ https://www.tecmint.com/install-apac...-ubuntu-20-04/ ...since you've not allowed things through your firewall, opened any ports, or seemingly looked at the permissions. Because this: Quote:
|
Quote:
This was a test I just did on my system using your permissions. Code:
$ sudo mkdir newdir |
Quote:
Quote:
Quote:
Quote:
Quote:
What I have done is to set the permissions for the file to be the same as what the permissions were for the /var/www/html/index.html that was installed (by Apache I presume). I will make this post for now and try to make another post with details of the permissions that I now have. |
Quote:
Access like that is a little convoluted on the EXT series of file systems. So for EXT4, which is the default for most distros, it involves some extra steps to share write access between several accounts. The web server runs as under a separate account for the purpose of least privilege / privilege separation and for static pages, the web server account only needs (and should only have) read access, specifically o=rx for directories and o=r for files. If you are setting up WordPress, then that counts as an additional account and it will need write access to specific directories and files. But worry about that later, after you have the static pages demo going. With WordPress, Again I'd recommend consideration of a static site generator as a choice among your demos if you're not going to use some of the functions which actually require a full CMS. WordPress is quite popular but requires a lot of attention, such as basic maintenance, because the default is to transfer updates unsigned over FTP (which I see as effectively a backdoor) or else do the WordPress updates by hand. Add to that comment moderation if you allow visitors to post comments on the site. On a popular site it can be almost a full-time job to delete spam quickly. Static site generators provide bells and whistles for the site's maintainer but publishes the result to the public as static HTML. That gives most of the advantages of a full CMS for those editing the pages, but without as many moving parts. K.I.S.S: if it's not there, it can't break. Static site generators include Hugo, Pelican, Jekyll, Publish, Lektor, Cactus, Nikola, and many more. tldr; I ask, what functionality you need out of your demo site(s) ? |
Quote:
Quote:
|
Quote:
EDIT: computersavvy, I stand corrected. The permissions should be 774, not 764 as I posted initially. Not sure if I wasn't paying attention or it was a typo, but the results are them same, regardless. Good catch. |
Quote:
|
All times are GMT -5. The time now is 09:29 PM. |