Configuring apache web server- web pages permissions SOLVED

Kernels & Hardware, configuring network, installing services

Configuring apache web server- web pages permissions SOLVED

Postby keithostertag » 2017-07-16 23:47

I've got a LAMP server installed on an old Dell laptop (32-bit) running kernel 3.16.0-4-686-pae at home on my lan.

I'm unsure where to put my web pages... the docs say the standard place is /var/www/html, and that's fine except since that path is owned by root it makes it very awkward to edit my web pages.

I want to be able to edit my web pages remotely from another machine on my network.

Usually I edit remote pages by using ssh to log into the server and then use nano, and I can do that, but still it becomes awkward (or impossible) when I want to, for instance, place an entire directory tree under there (like when unzipping a zip file with fonts or github jquery plugins, etc). And of course I can't ssh as root, so I have been ssh into my personal account then using sudo to change the permissions on directories that I create under /var/www/html/ and moving things around, which I feel must be the wrong way to go about it.

What's the standard way? For instance, can I edit some config file which will tell apache to allow subdirectories from my home account? Or maybe some method to create virtual paths? What's the standard method? I find the apache docs confusing, but this must be a very common scenario.

Also, is there a way to use a gui editor (like Atom) on a remote machine to edit my web pages across the network on the server?

This server is not reachable from the Internet- I'm using it just on my local lan to study web development (javascript, AJAX, python, database access, etc).

Thanks if you can steer me in the right direction.

Keith Ostertag
Last edited by keithostertag on 2017-07-23 13:55, edited 1 time in total.
keithostertag
 
Posts: 22
Joined: 2011-07-29 18:29

Re: Configuring apache web server- editing web pages permiss

Postby pylkko » 2017-07-17 06:03

For security reasons this is how apache and Debian work. If you are behind a firewall/router and the box is only accessed locally, then perhaps just allowing root ssh would be the easiest in your case. Realize that if your router is breached, then attackers will try brute forcing your root. Apache does also allow changing the user/folder etc.
User avatar
pylkko
 
Posts: 967
Joined: 2014-11-06 19:02

Re: Configuring apache web server- editing web pages permiss

Postby dilberts_left_nut » 2017-07-17 07:48

Just chown -R youruser /var/www/html - it doesn't need to owned by root, just not www-data.

Yes, you can use a gui editor. Easiest is via sshfs (to mount the tree locally) or just directly via sftp, depending on your file manager helpers (gvfs or kio-slaves etc).
AdrianTM wrote:There's no hacker in my grandma...
User avatar
dilberts_left_nut
 
Posts: 4614
Joined: 2009-10-05 07:54
Location: enzed

Re: Configuring apache web server- editing web pages permiss

Postby TonyT » 2017-07-17 11:02

Your site should be in your user /home/public_html directory.

SSH into the server as a user (not root) and do:

mkdir /home/<your user name>/public_html
sudo a2enmod userdir
sudo service apache2 restart

a2enmod activates apache modules, here specifically the userdir module.

Access your Web docs locally like so: http://LAN IP of server/~username/

In the future, SSH to the server using your user account, not root. You can use gFTP to SSH to the server and edit documents using your default text editor.
TonyT
 
Posts: 467
Joined: 2006-09-04 11:57

Re: Configuring apache web server- editing web pages permiss

Postby keithostertag » 2017-07-17 13:29

Hi Tony-

Thanks!

I followed your directions, and got no errors, but so far it is not working for me. Server is named "bob", user is "keith".

I created on bob a /home/keith/public_html/index.html and a /home/keith/public_html/hello.html

But now when I goto http://bob/index.html or http://bob I'm given the default Apache2 Debian Default Page from /var/www/html. When I goto http://bob/hello.html I get a 404 not found (Apache/2.4.25 (Debian) Server at bob Port 80)

When I
Code: Select all
ls /etc/apache2/mods_enabled
I can see both userdir.conf and userdir.load are there.

/etc/apache2/mods-enabled/userdir.conf says:
Code: Select all
<IfModule mod_userdir.c>
   UserDir public_html
   UserDir disabled root

   <Directory /home/*/public_html>
      AllowOverride FileInfo AuthConfig Limit Indexes
      Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
      Require method GET POST OPTIONS
   </Directory>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


That's after I ran sudo service apache2 restart and cleared the browser cache. So I must still be missing something, can you correct me?

Thanks,
Keith
keithostertag
 
Posts: 22
Joined: 2011-07-29 18:29

Re: Configuring apache web server- editing web pages permiss

Postby TonyT » 2017-07-17 18:44

Access your Web docs locally like so: http://LAN IP of server/~username/

That means to access your server from another computer on your LAN.
On the server you can try bob/~keith (tilda character preceding keith)
TonyT
 
Posts: 467
Joined: 2006-09-04 11:57

Re: Configuring apache web server- editing web pages permiss

Postby keithostertag » 2017-07-17 18:56

Oh... OK, that works!

I am accessing from my LAN... from another machine on my home network, not from the Internet. SO yes, http://bob/~keith goes where I wanted it to go, and gives me a way to test things that don't work without accessing a server (like AJAX requests).

Thanks Tony!
keithostertag
 
Posts: 22
Joined: 2011-07-29 18:29

Re: Configuring apache web server- editing web pages permiss

Postby TonyT » 2017-07-17 21:36

keithostertag wrote:Oh... OK, that works!

I am accessing from my LAN... from another machine on my home network, not from the Internet. SO yes, http://bob/~keith goes where I wanted it to go, and gives me a way to test things that don't work without accessing a server (like AJAX requests).

Thanks Tony!

Well done!
FYI, you can add users to the server if need be for testing multiple sites. Whenever I need to do a site for a client I usually will create an account on my server and test things there, then move the files to the actual Web host server. All local sites in username/public_html/ are accessed using ~username.
TonyT
 
Posts: 467
Joined: 2006-09-04 11:57


Return to System configuration

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable