0

I've done several hours of research. I am running Ubuntu 22.04, I am on the latest release and I am not doing anything special or fancy to my computer. I've gotten to the point where I successfully am able to get my pages to display PHP properly, so, that isn't an issue. I would think that it would be easy to find out documentation to successfully create aliases. I notice there are some courses from LinkedIn Learning in their library, however, they are from 2018. I wary of about Apache especially when I've read elsewhere that there have been changes between versions 2.2 and 2.4 for Apache. This is my code so far. When I type in test1, it does not link to the file. These are the permissions for my files so far

4-rw-r--r-- 1 jake jake 19 Jun 13 02:30 index. 
4-rw-rw-r-- 1 jake jake 19 Jun 13 02:46 test.html.

<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is/home/jake/Documents/coding #used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

Alias "/test1" "file:///home/jake/Documents/coding" <Directory "file:///home/jake/Documents/coding/home/jake/Documents/coding"> Options Indexes MultiViews FollowSymLinks AllowOverride None Require all granted </Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with &quot;a2disconf&quot;.
#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

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

Jake
  • 29
  • Rather than random "research" I would first pay more attention to the basics such as careful copy-pasting. For example # value is not decisive as it is/home/jake/Documents/coding. Or more importantly <Directory "file:///home/jake/Documents/coding/home/jake/Documents/coding"> which contains an obvious problem you haven't noticed aside from the fact that using URIs instead of plain absolute paths isn't going to work. – Martin Thornton Jun 13 '22 at 12:59
  • The # will comment it out anyways? Secondly, I tried it with and without the file and it still didn’t work, so, I would suggest your comment is extremely unhelpful and suggests I haven’t tried it the normal way? – Jake Jun 13 '22 at 16:57
  • There are other people who have had issues like mine- https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website?noredirect=1&lq=1, when I talk about research, that should be obvious by my links. – Jake Jun 13 '22 at 16:58
  • Your question suggested that. Do you still not see the problem with /home/jake/Documents/coding/home/jake/Documents/coding. – Martin Thornton Jun 13 '22 at 17:01
  • Unless someone else has a better idea is <a href="https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website">this correct</a>? Should you never even think about trying to make your folder point somewhere else in the first place? I have seen other people try to do this and they have not been successful. What's interesting is anything by default outside of the Apache 2 does not seem to work. At first glance and after my research, I get the impression that it is actually hard to access by default. While they let you change a whole lot, – Jake Jun 13 '22 at 07:38
  • @Jake you realize you duplicated your path twice right? That's the issue Martin is referring to. You probably did NOT mean to copy/paste your home directory path there twice in your config. – Thomas Ward Jun 13 '22 at 17:05
  • @ThomasWard umm no? According to the documentation, you are supposed to first put it in the Alias, and then, in the directory xml tag (https://httpd.apache.org/docs/2.4/mod/mod_alias.html)? – Jake Jun 13 '22 at 18:53
  • @Jake you're looking at the wrong line. Look at the line AFTER the Alias line. This one is incorrect, the file path is wholly incorrect. <Directory "file:///home/jake/Documents/coding/home/jake/Documents/coding"> <-- Nonexistent Directory, so your Alias 403ing is because you don't define it in your config. You shouldn't need to have double entry for your directory paths here - I guarantee you 100% that /home/jake/Documents/coding/home/jake/Documents/coding does not exist on your system. Your alias may be right, but your Directory configuration is wrong. – Thomas Ward Jun 13 '22 at 18:57
  • Further, file:// is a URI, NOT a directory path, so your Apache configuration will not work in the Directory declaration because it needs the actual paths on disk not your file:// URL. – Thomas Ward Jun 13 '22 at 18:57
  • I’ll try it with that fix, but, I could swear that I tried it without the file:/// and the issue was still the same. I will confirm later. I would not have made this post if I didn’t try just with the /home directory and not using the file:///. – Jake Jun 13 '22 at 20:45
  • @ThomasWard this is my code right now- "Alias "/test1" "home/jake/Documents/coding" <Directory "home/jake/Documents/coding/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Require all granted ", when I go to the Alias /test1, I am still getting the error. I now see the duplicate error that I made. That fix didn't work. – Jake Jun 13 '22 at 21:48
  • Now that I fixed that error, I'm getting a path not found issue @ThomasWard – Jake Jun 13 '22 at 21:54
  • @ThomasWard hi, I have come across a workaround which involves using soft links pointing the /var/www folder to another folder outside of the /var/www. While it is very hard and seems to be sandboxxed going the outside in, I seem to be able to work going the inside out. After I learn more about the topic, can I mark this as a potential answer later? – Jake Jun 14 '22 at 05:35

0 Answers0