Discuss Scratch

SC_DStwo_Master
Scratcher
100+ posts

Apache help?

I'm trying to set up a basic web server for downloading files but I keep getting this error:
The requested URL /example.ipa was not found on this server.
When it's clearly there in the folder I have assigned the server:

Here's my apache config:
<VirtualHost *:80>
ServerAdmin
ServerName nyap.io
DocumentRoot /home/nyap/nyapio/
<Directory /home/nyap/nyapio/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /home/nyap/nyapio/logs
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/nyapio/access.log combined
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here's the html (so far):
<!doctype html>
<html>
<body>
<a href=“example.ipa”>Clicky</a>
</body>
</html>

Last edited by SC_DStwo_Master (Sept. 26, 2016 20:20:57)

Flamekebab
Scratcher
1000+ posts

Apache help?

I'm no expert on Apache but let's take a look at one of my hosts files:

<VirtualHost *:80>
ServerAdmin admin@fox-box.co.uk
ServerName www.fox-box.co.uk
Serveralias fox-box.co.uk
DocumentRoot /var/www/foxbox
<Directory />
Options FollowSymLinks
AllowOverride ALL
</Directory>
</VirtualHost>

I wonder if the issue is essentially one of permissions? Doesn't Apache normally run as a different user and as such not have access to your home folder?

What happens when you use the more common /var/www ?
SC_DStwo_Master
Scratcher
100+ posts

Apache help?

the website loads fine with the /var/www/index.html page, and when I get rid of it:
awesome-llama
Scratcher
1000+ posts

Apache help?

Maybe this question is better suited in the advanced topics forum. There is more chance that someone can help.
https://scratch.mit.edu/discuss/31


Flamekebab
Scratcher
1000+ posts

Apache help?

Hmm, perhaps I'm right then.

You could try modifying the owner of the folder to be owned by whichever user Apache is running as and see whether that works.

awesome-llama wrote:

Maybe this question is better suited in the advanced topics forum. There is more chance that someone can help.
https://scratch.mit.edu/discuss/31
That forum is for advanced Scratch topics. This question would be a better fit for something like SuperUser.
awesome-llama
Scratcher
1000+ posts

Apache help?

Flamekebab wrote:

Hmm, perhaps I'm right then.

You could try modifying the owner of the folder to be owned by whichever user Apache is running as and see whether that works.

awesome-llama wrote:

Maybe this question is better suited in the advanced topics forum. There is more chance that someone can help.
https://scratch.mit.edu/discuss/31
That forum is for advanced Scratch topics. This question would be a better fit for something like SuperUser.
It is for anything advanced.

AT sticky wrote:

What should I post here? What shouldn't I post here?
If you need help about a project, help with advanced math or physics, or help with computer science or programming languages, you can post your question here.


Paddle2See
Scratch Team
1000+ posts

Apache help?

Let's try it over in AT for a bit and see if any of the smart folks over there can figure it out

AT is for advanced Scratch - and non-Scratch topics.

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
SC_DStwo_Master
Scratcher
100+ posts

Apache help?

Flamekebab wrote:

Hmm, perhaps I'm right then.

You could try modifying the owner of the folder to be owned by whichever user Apache is running as and see whether that works.
I used chown to change /home/nyap/nyapio to root, made no difference
I did it recursively to change the subfiles/folders to root too and I also tried restarting apache. No difference, it still shows nothing
robinp
Scratcher
100+ posts

Apache help?

It looks like the virtual host config is being ignored. I also don't understand why you need virtualhosts for this? you can ignore virtualhosts and just set the global document root the in apache config file.
If you post your apache config via pastebin we could help you further

System Administrator | Portfolio | My Blog | Web Developer
Flamekebab
Scratcher
1000+ posts

Apache help?

SC_DStwo_Master wrote:

Flamekebab wrote:

Hmm, perhaps I'm right then.

You could try modifying the owner of the folder to be owned by whichever user Apache is running as and see whether that works.
I used chown to change /home/nyap/nyapio to root, made no difference
I did it recursively to change the subfiles/folders to root too and I also tried restarting apache. No difference, it still shows nothing
Surely that's pretty much the opposite of what you want? The user Apache runs as definitely can't access files that belong to the root user. Find out which user your distro uses for Apache and set the files to that.
SC_DStwo_Master
Scratcher
100+ posts

Apache help?

I tried copying /var/www/html to my ssd (so it should have the exact same permissions) yet apache still complains that I'm not allowed to access my own server (You don't have permission to access / on this server)

I'm confused so I think I'll just keep it at /var/www/html for now, thanks for the help though

Last edited by SC_DStwo_Master (Sept. 27, 2016 20:06:36)

Flamekebab
Scratcher
1000+ posts

Apache help?

You did what?
In the context of a *nix file system what you said makes no sense, at least the way I'm reading it. It sounds like you need a bit more of a grounding in the fundamentals.

Hard disks, SSDs, and anything else either host the root filesystem or fit into it. There can be only one root filesystem.
For example on my media centre the root filesystem is on the SD card and everything else attaches to that. There are two hard disks connected to it at /media/animated and /media/share1 for example.

If you attach a drive to the machine it'll be somewhere like that. Copying the contents of the /var/www/html directory onto it will mean a copy of the files are somewhere on (e.g.) /var/media/SSD1/

Anyway, stuff that's relevant to the problem at hand - users. In *nix systems there are different user accounts, sure, but we're not just talking about people who log into the system. You can find out which users exist by looking in /etc/passwd

So on my media centre there's the following users:
osmc@Columbia:~$ cat /etc/passwd

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:103:systemd Time Synchronization,,,:/run/systemd:/bin/false
systemd-network:x:101:104:systemd Network Management,,,:/run/systemd/netif:/bin/false
systemd-resolve:x:102:105:systemd Resolver,,,:/run/systemd/resolve:/bin/false
systemd-bus-proxy:x:103:106:systemd Bus Proxy,,,:/run/systemd:/bin/false
messagebus:x:104:107::/var/run/dbus:/bin/false
avahi:x:105:108:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
ntp:x:106:110::/home/ntp:/bin/false
statd:x:107:65534::/var/lib/nfs:/bin/false
sshd:x:108:65534::/var/run/sshd:/usr/sbin/nologin
osmc:x:1000:1000::/home/osmc:/bin/bash

Users that can actually login have home folders listed (in this case /root and /home/osmc ). That said other users run things.
If I understand correctly this is done to keep the system secure (but don't quote me on that!). Essentially user www-data can't access your personal files and only handles stuff related to web hosting. Root can access everything (which is why traditionally one should never use the root user account for day-to-day use) but stuff belonging to root is off-limits to other users.

That means that if you set /home/nyap/nyapio to belong to the root user then no other users are allowed to access the files (and so you'd expect to get a permission denied error).

If you're running Ubuntu (and probably a fair few others) then Apache runs as www-data. Your home folder is inaccessible to the www-data user. Try chown the folder to www-data (or whatever is the correct user - Google your distro and “Apache user” and see what pops up).
SC_DStwo_Master
Scratcher
100+ posts

Apache help?

Flamekebab wrote:

snip
I meant that I copied the html folder from /var/www to my SSD, changed the name to “nyaplocal”, kept the permissions and owner the same, and updated DocumentRoot accordingly. It should work, but it says I don't have permission to access / on the server

edit: I tried changing the user and group to www-data, but it made no difference

Last edited by SC_DStwo_Master (Sept. 28, 2016 15:55:12)

Powered by DjangoBB